How to write to a excel cells dynamically

Hi, I want to update a column which somewhere in middle . How can I do it using write cell or without using it ? Write Cell has this limitation wherein we have to pass the Cellvalue . I dont want to update my excel using Cell value as it would be hard coding again. Can I loop in and pass cell values in which my Bot can write the content?

1 Like

@Shailesh123 Yes you can

1)Create one integer counter variable and initialize with value 2
2) Use for each row
3) Use Write cell activity pass range with ”B”+counter.tostring with urvalue
4) Increment counter variable assign counter = counter+1

yah that would be fine
well with write cell it will work fine
if wee are inside the for each row loop, then in the write cell activity , the cell value must be like this
if “C” column is to be updated
then the cell value be like “C” + (yourdatatablename.Rows.IndexOf(row)+2).ToString
where row is the variable from for each row loop

this will update the column in exact cell with resspect to which row we are in iteration inside tthe for each row loop
Cheers @Shailesh123

1 Like

Hi @indra- buddy I dont want to mention “B” . I want it entirely dynamic .

@Palaniyappan- unfortunately here I don’t know if my column belongs to C or D or some other cell.

You mean like we are not sure where to update the value
If we have B that’s fine
I just mentioned C as an example
Cheers @Shailesh123

@Palaniyappan Yes I am not sure where to update the value . All I know is I should Update the values of column RATE** from my excel sheet . So I am using an If condition to check the Column Name and if Its RATE I want to Write Data to the Column RATE. But since in Write Cell we can pass Cell values dynamically I am unable to write it .
Thanks in advance @Palaniyappan

1 Like

Good morning Shailesh,

Have you tried using the “LookUp Range” activity for the entire row where your headers are present (ex: 1:1) and searching for the word “RATE”?

From here, you’ll know the cell location based on the Result output and can write your desired value(s) into the remainder of the column.

2 Likes

Hello Good evening @chenderson- I am glad the solution provided by you worked !! I just had to do a little string manipulation to get rid of the Number from the Cell Address .

Thanks a lot !! :smiley:

That’s great news Shailesh, I’m glad to hear it!

Please feel free to mark that post as Solution if it solved your problem :smiley:

what if I want to update the first row(A1 or B1 and so on) means 1 will be constant so how can I change the Letters

@Ejaz44 Loop in your data table and in the write cell give row(index).ToString