How to iterate through columns

excel
loop
uiautomation
studio
#1

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

Untitled

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.

Project13.zip (623.7 KB)

0 Likes

#2

@Serran_Neru

Have a look into this post

0 Likes

#3

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?

0 Likes

#4

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.

0 Likes

#5

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.)

0 Likes

#6

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

#7

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

0 Likes

#8

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

Regards…!!
Aksh

0 Likes

#9

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.

0 Likes

#10

Hi i have a string $10-50 . i want 50 how can i get testString.Substring(testString.LastIndexOf("")+1,testString.Length-1)

error is coming

0 Likes

#11

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.

0 Likes

#12

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

0 Likes

#13

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

0 Likes

#14

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.

0 Likes

#15

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.

0 Likes

#16

DateColumnMatch&Range.zip (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

0 Likes

#17

yes Thank you.

0 Likes

#18

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

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

0 Likes

#19

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

0 Likes

#20

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

0 Likes