Automating reading a range from Excel and do a search with this batch until the sheet is over

Hi all, I’m new to UiPath and was trying to do a simple automation flow. here’s a brief about it:
I’ve an excel sheet that contains 2 columns, I want to take batches of rows (10 rows at a time) and to be saved somewhere (maybe a variable) with comma separating them so i can execute a search on website. (this’s where I’m stuck)
and after that click some download button on that website and repeat until the file is over.

can someone please guide me how to execute the previous flow?

  1. Read Excel Data:

    • Use the “Excel Application Scope” activity to open the Excel file.
    • Inside the scope, use the “Read Range” activity to read the entire Excel sheet into a DataTable variable.
  2. Batch Rows and Store in Variable:

    • Initialize an empty string variable (let’s call it batchRows).
    • Use a loop (e.g., “For Each Row”) to iterate through the DataTable.
    • Inside the loop, add each row’s value from the desired columns to the batchRows variable with a comma separator.
    • Keep a counter to track the number of rows added.
    • When the counter reaches 10, store the batchRows value in another variable (e.g., currentBatch), and reset batchRows for the next batch.
    • Continue this process until all rows are processed.

In this example, each batch of 10 rows is stored in the currentBatch variable as a comma-separated string. You can then use the currentBatch variable to execute searches on a website or perform other actions.


  • Inside the loop, add each row’s value from the desired columns to the batchRows variable with a comma separator.

after the “For each row in data table” i tried the “write line” activity and set the variable like this: batchRows = row + ", "

but it’s not working. so i guess i’m doing something wrong. can you please explain more?

Please find this code
i have taken an excel and done
New (9.7 KB)

Hope it works
please let me know if you get any issues

Thank you so much for taking time to create this. however, when i tried to run it i got the following error:

please change coloumn names
i have given the column names from the excel I have taken
in value to save change Batchrows in the begining

BatchRows + CurrentRow(“Your colomn name 1”).ToString + “,” + CurrentRow(“your colomn name 2”).ToString + “,”

Did the issue resolve?

actually this’s not what i want. i want to create a batch of 10 rows (for the same column)

also when i printed the currentbatch it has all the values of that column not 10 by 10

updated (9.7 KB)

Try this

i think there’s still an issue with getting the batch of rows and assign it to the currentbatch
if you check these scr shots you’ll notice the counter is not getting reset and it keeps adding rows even if the batch contains 10 rows already

here’s how and where i put the activity to print the variables


Here is a sample implementation of batches

basically we are batching the data and creating a datatble if you need a column of chunks 10 as string we can do that as well into a string…Here dt is original data and dt1 inside loop is the chunks of 10

chunks - Enumerable.Range(0,Cint(Math.Ceiling(dt.RowCount/10))).ToArray
copy to table - dt.AsEnumerable.Skip(currentItem*10).Take(10).CopyToDataTable

BlankProcess - Copy (8).zip (5.2 KB)


Thank you for taking the time to solve my issue.
whenever I’m running this batches file i’m getting the following error:
For Each: Object reference not set to an instance of an object.


As per error looks like datatable is empty…you have to first add the data…if you are trying the sample i sent…I did not add data in it

Cheers (10.5 KB)

Try this
hope this helps