How to distribute one excel list evenly to multiple sheet

I have 10 rows in master sheet and want to evenly distribute the list to 3 different worksheets. Do you know how I can do that?

Input
Master list:
image

Output:
Team 1 sheet:
image

Team 2 sheet:
image

Team 3 sheet:
image

Thank you so much!

@ndtran85

Follow the steps

  1. Read the data into dt
  2. For each loop with Enumerable.Range(1,Cint(Math.floor(dt.RowCount/3)))
  3. Now inside loop use write range with sheetname as "Sheet" + currentitem.ToString and datatable as dt.AsEnumerable.Skip((currentitem-1)*0).Take(3).CopyToDataTable`
  4. After then loop to append remaining extra rows use if condition with (Cint(Math.floor(dt.RowCount/3))*3).Equals(dt.Rowcount)
  5. On then then side do nothing and on else side use append ramge with sheetname as "Sheet" + Cint(Math.floor(dt.RowCount/3)).ToString and datatable as dt.AsEnumerable.Skip(Cint(Math.floor(dt.RowCount/3))*3).CopyToDataTable`

Cheers

I got an error message at the append range activity

image

image

@ndtran85

You missed .RowCount

Use dt_masterlist.Rowcount/5

Cheers

In sheet value write:

“Sheet”+Cint(Math.Floor(dt_masterlist.Rowcount/5)).ToString

And same in datatable value in between as well : Math.Floor(dt_masterlist.Rowcount/5

Thanks,
Ajay Mishra