Increase row count

I have 3 columns in data table, using for each row I am reading all the values in data table.
Now in between the code I need to skip one row and increment the count and run with the next row.
Is there any logic to execute the code in for each loop activity ?

Hi @hemanth_chinna,

Use if condition to to skip the row.(your condition)

Regards,
Arivu

Hey.

Typically, you would embed the body of the For Each with an If condition, so if a certain criteria is met (to skip rows) it will do nothing in the false side.

For each row in dt1
   If row(0).ToString.Trim <> ""
       Process row
   Else
       <do nothing>

On the other hand, it’s more efficient if you can skip the rows before you enter the For each. Like for example, if you wanted to skip rows where there is a blank value you can set the datatable to an array of rows that meet your criteria and loop through that

For each row in dt.AsEnumerable.Where(Function(r) r(0).ToString.Trim<>"").ToArray

In that version, you will need to use a regular For Each (not For Each Row), then set the TypeArgument to “DataRow”

Hope this is helpful.

Regards.

sample.xlsx (8.8 KB)

Consider this as an input file, I am executing the code to get names, meanwhile few name are not necessary, So It should increase the count and go to the next name in a row.