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?

0 Likes

#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

1 Like

#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.

1 Like

#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?

0 Likes

#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

0 Likes

#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

1 Like

#8

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

0 Likes

#9

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

0 Likes

#10

An example from my answer or from AkshaySandhu?

0 Likes

#11

From yourself if possible?

0 Likes

#12

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

0 Likes

#13

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.

0 Likes

#14

Hi Darren,

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

0 Likes