I want to remove rows with a cell value in 1 column below 40


#1

I have a spreadsheet where in one column I calculate days since creation. When this spreadsheet is compiled, I want to delete any row which has a number of less than 40.

So Column N has a header of ‘Days Since Creation’. I want to find any cell in this column with a value of 39 or less and then delete the entire row in which this is held.

Can anyone help?


#3

U could read the spreadsheet to a Data Table.
After that, iterate through the Data Table and make the verification. If the number is less than 40, store the index of row and add 1 to the index. After this u could delete the row in excel with this index


#4

hello @thetruestorey
If you are sure column ‘Days since creation’ will contain only number the try below
read your file in datatable dt
dt.Select(“Convert([Days since creation],‘System.Int32’) > 39”).CopyToDatatable

you can then output this dt into new file or override the existing sheet’s data.


#5

So if I Read Range and extract it to dt for example, would I then do a ‘for each’ with ForEach row in dt then ‘Get Row Item’ followed by an ‘If’ or am I way off?


#6

Yes!
In the ‘For Each Row’ u don’t need the ‘Get Row Item’, u could use a simple ‘Assign’ that stores the value for the correspondent cell


#7

Ah ok. I think that makes sense. I’m still very new to this but all of this knowledge is very helpful. Thank you


#8

Thank you!
If u need any support just let me know!


#9

Would it be possible to get an example of how to do this?


#10

An example from my answer or from AkshaySandhu?


#11

From yourself if possible?


#12

Could you provide the file or a sample of it?
Just to make more useful for you