For each row into For each row!

Hello Everyone,

First of all i have a datatable(DT1) that taken by data scrapping.It has 10 row.
Also i have a excel sheet that including 5 person(DT2).
I want to write names of person one by one for each row of DT1.
But robot write all 5 person for each row of DT1.
it mean its written 50 times!!

if my issue is not clear i can try to explain better.Please let me know.
is anyone can help me?
Thank you

Hi @erso88

Try this :point_down:

1 - Read Range DT2
2 - Extract DT1
3 - For Each Row, using DT2
4 - Write Range DT1, using DT2 rows…

Does this works for you ?

Thank your for your interest mate.
But honestly i couldnt understand what i should.
Can you design an example project for me?
I am so new in uipath.Sorry

hi @erso88

When Your using second for each row in last use break activity so that it will leave that dt2 row and again it will go for Dt1


If this’s your solution please mark as solution


1 Like


Sure, here’s an example using only excel files… :point_down: (68.1 KB)

Thank you for your time.
But rows count of datatables are not equal each other.
DT1 has 10 row and DT2 has 5 row.
I need to write each row of DT2 at each row of DT1.
as like;
DT1 1st row=DT2 1st row
DT1 2nd row=DT2 2nd row
DT1 3rd row=DT2 3rd row
DT1 4th row=DT2 4th row
DT1 5th row=DT2 5th row
DT1 6th row=DT2 1st row
DT1 7th row=DT2 2nd row

I hope i have explained with my terrible english :slight_smile:

Thank you for your time.But doesnt work. :frowning:

Then use for each for DT1
If- ReloopCount= DT2.Rows.Count
Else- nothing
Row(Column No or Name )=DT2.Row(ReloopCount)(ColumnNo that you know)

can You plz share me your workflow screenshot?

Hello @erso88,

Not sure if you were trying to write this in Excel, but hopefully my solution below addresses the issue: :slight_smile:

dt2Name is a string that contains the result of the Lookup DT2 activity. I defaulted 2 to rowNum because I have included a title/header in row 1 of the Excel file I’m writing to. The Lookup DT2 contains the following configuration:


When I tried to run the bot, the Excel file looked like this afterwards:

For my test data, my DT1 contains the following names: Name 1, Name 2, Name 3, Name 4, Name 5, Name 1. My DT2 contains the following names: Name 1, Name 2, Name 4. Screenshots below:



My friend this is amazing.Thank you for your effort.its work. but its just matching.
Let me explain my situtation again;
I have a datatable that taking from website.So row counts will be unknown.
in the other hand i have fixed datatable taking from my excel folder which including 5 name.
Lets say first datatable that taking from website has 6 row.And my other datatable has 5 row which including names.
I want to write names like this,

DT1 rows - DT2 Names
row1 - Name1
row2 - Name2
row3 - Name3
row4 - Name4
row5 - Name5
row6 - Name 1
if there is 7th row in DT1 - Name 2
if there is 8th row in DT1 - Name 3

I mean there will not be same values in both datatable.

But thank you so much for your effort.That will be used by me in the future projects.

Hello @erso88,

In that case, if my understanding is correct, you can use the following logic:

The first assign in While contains the following code:

result = (From dtrow In DT2 Select dtrow).Take(dt2RowCount).CopyToDataTable

The 2 other Assign activities in While are:

rowCount = rowCount - dt2RowCount
rowNum = rowNum + dt2RowCount

The first assign under the If contains the following:

result = (From dtrow In DT2 Select dtrow).Take(rowCount).CopyToDataTable

The Write Range activities use the rowNum variable.

1 Like

Thank you for your time my friend.
I tried the flow but something gone wrong about “write range”
Probably i am done something wrong about variable.
I will keep try and let you know about results.

1 Like

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