How to iterate every 10 rows in excel

Hello everyone !

Need help on how to iterate the excel value every 10 rows.

Actually, I need to copy all these value

image

to that sheet

Thanks in advance!

As you can see, first need to copy the value in the 20220622 row, after that to the 20220623 row.

Dt2 = Dt1.Clone Dt2=Dt1.AsEnumerable().Take(10).CopyToDataTable()

Thank you. But can you explain a lil bit how to use that code? I’m sorry, noob here. :sweat_smile:

Hello!

First use activity read range with source range (“D2:D12” for example) without checking “AddHeaders” and storing the data in a DataTable. Then use the write range activity with target range (“F2” for example) without checking “AddHeaders” to write the DataTable data.

Thank you.

But after that, I want to copy the value but need to paste on the 20220623 row. So, can I know the solution how to do that

Hi @fizzuraimi

If the first table is given like this

image

and the second excel is like this

image

Then you can proceed like this

XAML for reference

10Rows.xaml (7.3 KB)

1 Like

Dt1.AsEnumerable.Skip(0).Take(10)
Dt1.AsEnumerable.Skip(10).Take(10)
Dt1.AsEnumerable. Skip(20).Take(10) etxc etc

Based on the number of row you can perform

This is basically a combination of skip and take function
In the first case it will take first 10 and skip none
In second case will skip first 10 cases and take the rest 10 and so on

Thank you for your solution. But can you give some example how to use that?

1 Like

Hi @fizzuraimi

lets say you want only first 10 rows of that excel

Dt1.AsEnumerable.Skip(0).Take(10)

so this means --Take (10) would take first 10 rows and skip (0) means no skip

DT1 is ur datatable name

hope this helps
thanks

Oh I see, so do I need to use assign activity to put that coding?

1 Like

Yes Exactly @fizzuraimi

But I got that errors. :sweat_smile:

Do you know how to fix the errors?

change the type of dt_Input variable to datatable

Hi @fizzuraimi

Change the variable type to datatable please

The variable type already DataTable :sweat_smile: