Read Part of Excel Based on Certain Column Value. Split One major Excel to Two parts

Hi Hurmet,

I would probably:

  • Iterate through the full DataTable with For Each Row and declare a variable for the RowIndex
  • Get Cell Color with a range based on the RowIndex (careful, RowIndex 0 is usually row 2 in Excel)
  • If the color is yellow, use that RowIndex to copy your rows to a new DataTable like this: NewDataTable = FullDataTable.AsEnumerable.Skip(PreviousIndex).Take(CurrentIndex - PreviousIndex + 1).CopyToDataTable
  • Put the CurrentIndex as the PreviousIndex (+1) after and you can skip the first part that you already saved somewhere and take the second part of rows from the PreviousIndex to the CurrentIndex

Hope this helps :wink:

2 Likes