Loop through Columns and pasting the data into a web page

Hi :slight_smile:

The column number and row numbers are not fixed. I have attached a screenshot.

Columns can go beyond Z and same with rows.

How I do it manually:

  • I copy the whole column one by one excluding the header (ex: A, B, C… till ‘n’ Columns)
  • (In the screen shot i have selected only one column.)
  • Then paste all the cells under the header in a webpage.

I have have created a bot for this which can perform this task but it pastes only one row item at a time. Ex: It will paste: A2 then A3 then A4 and so on. Then it loops through column and pastes B2 then B3 then B4…

Each header acts as a web link for me. I just concatenate the cell value. For example in A1 cell :

xyz.com/df/2332019 (A1 cell value)

So when the BOT loops through each column, it opens a new webpage, where the corresponding values (rows under the header) need to be pasted. So each header acts as a a weblink (for reference i have hyperlinked it).

How can I create a loop for this?

Hi @Bhanu_Rathore ,

Just want to understand you want bot to click headers of the excel also ?

Is so then use below steps

1 - Read whole excel file from read range activity
2 - Iterate on each columns shown below
image

Here in item you will get the value of column.
If you want to implement click in excel then open excel and click on Text.

Now their are many ways to copy data
1 - As you have all the data in dt already then you can iterate each data of column and paste it on destination.
Or
2 - You can use Read Column and paste it on destination.
Or
Get last row of column and Read only that data and paste it on destination.

This whole part will remain in foreach loop.

1 Like

Hi @Bhanu_Rathore

You can also watch this video to learn more about looping through rows and columns in Excel / DataTable. It would help you.
Video: UiPath | Loop through Rows and Columns in Excel | Loop Excel/DataTable rows and columns in UiPath - YouTube

Best regards
Mahmoud

Hi,

Thanks for the reply.
Actually the input file can have n number of columns and n number of rows. (Dynamic)

Name of the headers is also not constant.

Could you please explain how i can execute Point 1 or Point 2?

Sorry Im new at this.
I just need to copy data under the header. For ex: A2:A8 in case of A column, B2:B6 for B column and loop until the last column (which is E in this case)

Hi @Bhanu_Rathore
Check this workflow
Main.xaml (12.6 KB)

Regards,
Nived N

Hi @NIVED_NAMBIAR

Thanks a lot for the reply.

This is working but it is entering each cell data one by one.
Like A2 then A3 and so on. I want the whole column A2:A8

As I mentioned. Rows can be of any number. If there are 300 rows for one column header then the bot would be slower than a human.

Hi @Bhanu_Rathore
U mean to create such hyperlinks for all cells at once ?

is it right?

Hi @NIVED_NAMBIAR
Thanks again for the reply.
Noo. Not creating hyperlinks or opening browser.

Forget hyperlinks.
I have intentionally hyperlinked this file for reference.

Each header acts as a web link for me. Iam able concatenate the cell value. For example in A1 cell :

xyz.com/df/2332019 (A1 cell value)

I just want to know how to copy the cells under the header column.

How to copy A2:A8, then B2:B6 and so on in a loop.

Take it like this:

I want to see these column values (A2:A8, B2:B6, C2:C5 …)in a message box in a loop for each header.

Hi @Bhanu_Rathore
Here check this workflow
It will row value under each column as a string seperating each value by new line
Main (1).xaml (10.8 KB)

Regards,
Nived N

Hi,

This is awesome. Thanks a lot.
Just one more thing: It is also reading the blank cells.

For ex: For “C Column” it is the 4 values + empty values

Oh , seems like some whitespacing issues is still there

check this one
Main (1).xaml (10.9 KB)

Regards,
Nived N

Hi @NIVED_NAMBIAR

This is Working just fine.
Actually i need to paste this data (which is appearing in message box) in a webpage field.

I used your code into a type into activity to paste it into a web page.
But It is entering the data (Through type into) but one by one. Ex: A2 then A3 . A4…
I tried simuting the type. But its not supporting it.

Like can u show how u need to enter the data

Hey @NIVED_NAMBIAR
Seems like i just need to add some delay. And its working perfect. Thanks a lot.

Can you suggest me from where i can learn this coding part? I’m using uipath from last 4-5 months and able to do basic tasks. But I also want to learn this coding as well.

Hi @Bhanu_Rathore
Check out @Anmol_Yadav videos on Linq: LINQ query in UiPath | Compact your code with the help of LINQ query - YouTube

You can get a good ideas around that

Also you can get resources from this forum itself

Sure. Thanks again!

1 Like

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