Count the results

Hi Community!

I have an excel sheet
variable1 = row(16).tostring, variable2 = row(0).tostring
If variable1 >=2
Then get variable2

How do I count the number of variable2 results from the IF statement? dt.rows.count.tostring counts the total number of rows. I want to count only the number of results from the IF statement.

Thanks so much for your help!

Hi @Jessica_Moseley

Are you trying to count the number of times where the columns 0 and 16 have non-empty values?

Outside For Each row assign count variable say Count=0
Then in IF condition where variable2 will be selected below that use Count=Count+1

so at the end you will get Total used variable2

No. I want to count the number of times column 16 has value greater than or equal to 2.

you can use the counter with initial value as 0 and when ever it is going to else block you can increase the counter with 1
this gives the number of times column 16 has value greater than or equal to 2

1 Like