Looping through multiple excel tabs and looping each row datatable

I’m trying to copy the data from my datatable to my main master list spreadsheet with lots of tabs.

in my datatable, if the category is under cat A, bot to search for tab cat A. and from there, bot to find the name and fill in age, occupation and company in their respective row

Hi @Popo - This can be done.

  1. Read your master sheet store it in a Datatable

  2. Apply a For Each Row Loop

  3. Use Read Range and the sheet name value as “row(“Category”)” store it in another Datatable

  4. Apply an IF condition to check Master Datatable row(“Name”) = Datatable1 row(“Name”). If it matches then, use write cell activity “C2” “E2” and “F2”

  5. In your IF condition you should use a Counter variable to increment, hence you can pass that value to write cell like this “C”&Counter, “E”&Counter and “F”&Counter


1 Like

for no 4.how to write the exact coding. I encounter error end of expression exgected

What was that no.4?


Hi @AnandKumar26

Im referring to s/n 4 of your previous post.

  1. I have created a datatable (name DT)
  2. Used for each loop to get all the tabs names (name DT1)
  3. Read range (DT1)

In my datatable(DT), there is header called “Category”

in my another datatable(DT1), the tabs are name “cat a”, “cat b” etc.

I want to use a if function, if DT row category is cat A, write data into cat A tab.
If DT row category is cat C, write data into cat C tab.

Im stucked at the if function and writing the data

You can mention in the IF condition row(“Category”).ToString=“cat a” then Read Range using the sheet name as row(“Category”).ToString

This should be inside For Each Row loop


so I should use for each activity first and then inside for each, use for each row?

For Each Row inside For Each Row along with IF condition