Process repeated for each multiple rows

We could use for each row to read the data in excel row by row, is it possible if we could do read for each 3 rows, and repeat the process to read the next 3 rows instead?

@christine.tzenghy, The question is not quite clear.

Sounds like you have 6 rows, and you want to read for first 3 and then seperately read for second 3. Is that correct?

Please provide a bit of detail.

hI, @SenzoD
As currently I read the row value from fileA and put into specific cells on fileB.

And each time FileB would need 3 rows of value from FileA (each row is the value of different years,I need values for 3 years each time on fileB), so I would like to repeat the process by reading 3 rows continuously at one time if possible.

Similar to for each loop, but instead of reading row by row, I would insert 3 rows of value from file A into file B before proceed to the next loop, close file B and repeat the process again etc

Hope this clarifies.


let me introduce a general approach that can be also adopted to more case specific details.


  • DataTable with 8 Rows
  • Segmentsize: 3

Following Building Blocks are used
Calculation of the numbers of segments:
with the Ceiling method the fractions are uprounded to the next Integer

with the Skip() and Take() Method the Rows for a segment can be retrieved.
the different segments are bult by following

and do fetch the different segment rows by:
does mean:

  • Segment0: dtData.AsEnumerable.Skip(0*3).Take(3).toList - Row:0,1,2
  • Segment1: dtData.AsEnumerable.Skip(1*3).Take(3).toList - Row:3,4,5
  • Segment2: dtData.AsEnumerable.Skip(2*3).Take(3).toList - Row:6,7

Detecting if a segment is incomplete or not the modulo function helps

Giving an impression on the processing result, refer to logs below:

Find starter Help here:
ForEach_Segment_RowSets.xaml (11.5 KB)