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

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?

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

1 Like

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.

1 Like

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?

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

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

1 Like

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

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

An example from my answer or from AkshaySandhu?

From yourself if possible?

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

TEST.xlsx (10.2 KB)

This is a cut down version but should allow the solution to be produced. I can then e-configure to the actual spreadsheet.

Hi Darren,

Sorry for the late response. I’m with a lot of work.
U already solved your question?