How to iterate through columns

I’m trying to iterate through columns (column A, B, C, D…) - to copy unfixed range of data and paste into a web.


Now I’m stuck to iterate through columns and specify the range in “select range” activity.

I’ve attached my workflow for your further reference.

Kindly provide some insight on how should go with this. (623.7 KB)


Have a look into this post

Hi Ranjith, I saw this post earlier, but I still unable to figure out what should I mentioned in the range in “select range” activity. Any idea on this?

I guess you were saying about the Select Range property in Read Range Activity. If you need to grab the entire sheets data into datatable variable then leave select range property as blank. And also check the Add Header property if your sheet has headers.

No, I dont have to grab the whole sheets data. I need to copy one by one (meaning all data from column A, column B and so on.)

I think maybe you could read the file as a datatable and then use a for each activity to loop through each column (item) and assign the values to another variable as say, an array of int, which you can then use for pasting elsewhere?

1 Like

Hi Djh, could you please show me an example. I still cant figure out.

you can use String.join like this

String ColA_Data = String.Join(Environment.NewLine,dt.AsEnumerable().[Select](Function(x) x.Field(Of String)(<Datatable_Col_name>)).ToArray())

Use Set to Clipboard Activity to set it on clipboard and use Get From Clipboard Activity to paste it


Get Column Data.xaml (13.3 KB)
Test Excel.xlsx (13.9 KB)

This is a simple way of reading the data form a single column int he attached excel file, you will see at the end it is just added to a string and then logged. I have repeated for column 2 but you can repeat for all columns.

Hi i have a string $10-$50 . i want 50 how can i get

error is coming

Hi @Djh

I have gone through your sample workflow but I am not getting correct solution to my problem. can you please look into it.

I am new to UiPath and I am trying to test facebook using excel sheet. I am able to loop the workflow using for each row activity successfully. For the first time the application is taking input value correctly. But, second time the application is taking empty spaces and unable to login facebook. Please find attached excel sheet and workflow.

FacebookTest.xaml (21.9 KB)
TestData.xlsx (9.8 KB)

Can anyone tell me how can I loop only the search field for the second time.

I have one excel data. and convert it to Datatable. i need to iterate one particular column from that datatable.???

Hi Bhaskar, sorry for the late reply! I believe you have now got your answer on a different thread

You could just create a string variable with the column name which you require (strColumnName), then use a for each row to iterate through your datatable, and put a log in the body of the for each, with ‘row(strColumnName).tostring’. This will will iterate through and log the data from that column. Obviously instead of a log you could be extracting that data, or putting it into a system etc.

Hi, I have one Excel with three sheet. In Sheet 2 i have two columns date, Last . I need to match that date with current and same time. I need to get the difference days of date and last date.

DateColumnMatch& (16.7 KB)

Is this what you need? it reads an excel with columns ‘Date’ and ‘Last’, and iterates through, where the ‘Date’ column matches today’s date, it calculates the range in days between ‘Date’ and ‘Last’, logging the result. If there is no match for today’s date then it logs ‘No Match’ with the date from the ‘Date’ column

yes Thank you.

use testString.split("-"c)(1)

this way you split the string by the “-” character and then chose the second string (which is index 1)

Hi I have doubt in one scenario: If Day is there instead of date in date column, for that I need to match the day with current day. If it matched get the current date. then find the difference of Last Date with current date

when you say ‘if Day is there instead of date’ do you mean instead of ‘01/03/2019’ it will say ‘Friday’?