Loop through Excel Table in specific row number

Hello everyone,
I hope anyone can help me with my problem.

I want to loop through a large data table in Excel, to take first 50 rows, add them in another Excle and then to repeat the same with the next 50 rows, and so on.

I managed to take the first 50 rows and save them in a new excel file, but that’s all.

@zhasmina.dimitrova

You can do the same for next 50 as well but as of now use append range instead of write range so that the data gets appended after the first 50 rows

Cheers

I am not sure how to handle the next 50 and then the next 50 results.
I am actually thinking is it possible to run the bot, and to have all files saved at one on different Excel files.

Hi, Check this out
Split the output data table into smaller data table which contain 50 rows per data table

1 Like

Thank you, @putera.timmy ! all of this was helpful.
I managed to loop through every N items and store them in separate Excel Tables.

However, I get only 2 tables:
Table1 - first 10 items
Table2 - next 10 items
Then the process ends. The rest of the excel file (the other rows) are not being used(looped through).

Do you have any idea why?

Did you already try to change your N items inside loop? or you can share screen shoot of your code

@putera.timmy Sorry, I got the notification now.

This is my code. The bot makes two tables, for the first 20 rows, and the next 20. The others rows are not being processed.

Untitled

you can try this, i have 50 data and split into 10 rows which is generates 5 files.

Here i attach the xaml and the file

split_row.xaml (10.8 KB)
tes.xlsx (15.8 KB)

Thank you, I will test it now.
But I am not able to open the .xaml file to see Assign values :confused:

ok,

int_range = Convert.ToInt32(Math.Ceiling(dt_2.Rows.Count / SegmentSize))
*SegmentSize is N items mine is 10, int_range and segmentsize both is integer type

and here for foreach properties

dt=dt_2.AsEnumerable.Skip(segment*SegmentSize).Take(SegmentSize).CopyToDataTable

1 Like

Thank you soooo much! I even was able to make different Excel files, starting with the segment number!
Thank you!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.