How to write to the same Excel cells as the original Excel spreedsheet

Dear UiPathers

I have to go through an Excel spreedsheet and enter some numbers into a website and retrive the information from the website and paste it in another Excel spreedsheet.

Below is an illustration of how the spreedsheet might look like.
image

After I read the cells and enter them on the website, I want to retrive the other piece of information the website gives me back, which is the adress of companies. This information I need to put in another Excel spreedsheet in the exact same order as the numbers. If a cell is blank then the other excel also need to have that cell blank.

A desired output can be seen below
image

You may assume, that I have correctly typed the numbers in and have retrieved the correct adress for the companies.

Below is a snippet of the code I am working on




However, doing this approach gives me this error
image

Any help is gladely appreciated!

Hi @nmjvk ,

As shown in the screenshot provided above, The Range Provided or the Cell name provided is invalid.

Could you let us know what is the Cell name that should be placed there according to you ?

Dear @supermanPunch

Thank you for replying. Of course I can. I want the cell range to be the current cell range of the old Excel spreedsheet. Please refer back to the very first and second picture. When the program looks at A1 which has numbers in it, I want the write cell to also have the cell range A1. Another example is when the program looks at B3 and C2, I also want the Write Cell to be B3 and C2. If the cell is blank I still want to write to the cell, just blank. So C1 in the original Excel spreedsheet will just be Write Cell (“”) for cell range C1.

Hope this makes sense for you, else, reply back and I will clarify further.

@nmjvk ,

In that case, Could you create index variables for both For Each Row In Datatable and For Each Activities. Let them be named as i & j.

Then in the Write Cell Activity you could use the Below Expression in the Range Property and check if it works :

Excel.Sheet("Ark1").Cell(UiPath.Excel.Helpers.ExcelUtilities.ConvertColumnIndexToColumnLetter(j+1)+(i+1).ToString)

Let us know if it gives out an error or doesn’t work as expected.

Hi @nmjvk ,

Will creating a clone of the source data-table and over-writing the cells that has the exact number with the address work?
You can then work within the data-table and perform write-range at the end.

Let us know whether it will work.

Dear @supermanPunch

I have gotten the desired output, however, all of my data starts at B1 instead of A1. Is there a way to fix this?

I assigned my variables to 0 and that still does not work. I also tried -1 just for checking and that also does not work. Any idea?

Nevermind, I got it working now. I forgot to re assign j to be -1 in the for each row in datatable.

Thank you for your help. I will accept your solution!

Have a great day forward

1 Like

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