Excel skip to the next row

Good Morning,
I have searched a see many examples on how to skip to the next cell but not one that skips to the next row.
Using a for loop after reading a range if I encounter a row that contains a specific value in row(0) I want to skip the next row and read its value in cell 1.

Thanks for your help

Under the assumption you’re doing this in excel (sorry if not);

Read the range to the datatable, then at the beginning of each ‘for each row’ loop increment a counter by 1. Note - if you are adding headers to the DT then you should initialize the counter at 1, so that the first row it reads will be recognized as row 2 of the spreadsheet. If you are not adding headers, initialize the counter at 0.
When it finds a matching row, add a break to come out of the loop, and then read cell - “A”+(yourCounter+1).ToString (assuming the value you need to read is in col A).

This will read the cell in the row after the last one processed during the for each loop.

Thanks for the response. The issue is once I break out of the for loop I wont be able to read additonal rows that meet that criteria. I was hoping for a skip line activity:(

I was able to solve using a Boolean

. So if I encounter a row than I set the value to true. The for loop proceeds and if the next row has a value I grab it. If it is null than I skip to the next occurrence of the original condition.

Thanks for your insight:)

1 Like

Please find SkipRow.xaml (10.0 KB). I have used simple comparisons to achieve this.

1 Like

Hi Madhavi,

your solution worked like a charm for me. :slight_smile:


1 Like