Update a cell in looped row

I’m currently working on a workflow to copy an account number and paste in an application to see whether the account number is found or not.
For copying the account number, I’ve used “for each row” activity to loop through my list (column B) in an excel.
So now, the question is - how do I update back in the excel (column A) as “complete” (if the account number found) or “pending” (if the account number not found) for respective account number’s row in the excel?


Hi Serran,

When you are going through your for each are you storing the row number in any form? This could be an arbitrary number that you increment each time you go through the loop and use as the row number in a write cell to write back to column A.

intRowNum = 2 (default row)

for each row in DataTable

\Do whatever you need to do. including some logic to say whether the it is found or pending.
write cell(“value”,irownum
irownum = irownum+1


hope that pseudo code makes sense.



picture talks louder than words. :smiley:



Great! Its working. Thank you so much for your great guidance.
However, the cell was updated starting from row 1 (which is my header).
Is it possible to write starting from row 2 just exactly as the same row where the respective account number are?
Hope you could help.

Assigne the counter to default 1.

1 Like

Thanks, but could you please be kind to show - what do you mean by “assign the counter to default 1”

in above image their is a counter “cnt” if you will assin it to 0 then it will access the cell like B1 because 0+1 = B1 and first is your header row so it will read your first cell B1 header.

if you will assign cnt value to 1 and then use cnt = cnt+1 then it will read cell B2 so on if you will increase counter inside loop. otherwise in above case only B2.

1 Like

Perfect, super perfect! You guys are awesome. Thanks.

is it “a”+cnt.Tostring?

hey @karthyk

yeah hear “a” will be your Column header Mapping name and cnt in above context an int counter so you are converting it into string :slight_smile:


I am writing bookname to excel.

Column header name is “bookname”.

In writecell I gave the range as “bookname”+cnt.Tostring.

But I am getting range not found error.

Kindly advice.


header will be your first row if you are opted for that in Excel read properties but here i m saying about column name mapping :slight_smile:.



If I give excel header value,

“A”+cnt.tostring… I am getting range not found error again.

Only when I give “A1”+cnt.tostring.

it prints the value but starts from row 10

I guess i have explained the reason in your other thread post :slight_smile: check over there :slight_smile:


hi @aksh1yadav,
I am writing some string array getting from regular expression in excel.But each time I want to increase row no. in same column.But after updating some cells script get stopped. Can you please provide me the solution.

Hey @Snehal1

May i know what kind of error you are facing?



I am trying to print the data of a row one by one. For this I have used a Do-While loop. But while executing the same, the values are getting printed in required Format. But at the end it is throwing an exception like I haven’t initialized the Object instance. Uploading the xaml file and the screenshot of exception. Could anyone pls help me out. Thanks in advance.
Main.xaml (7.9 KB)


Thank you…This is really helpful. But what if we have to increment the cells in single row…i.e., to move from left to right in the same row. Then the index will increment in this way right?? A1, B1, C1…
Any solution to print the row values one by one as you have mentioned for columns.


i try do to like the example in the beginning of the post but doesn’t work so i try the next one:

Counter = data1.Rows.IndexOf(row)

write cell
“Sheet1” - "C1+Counter.toString
textopage (that is from web)

for paste in excel the information by increment but it always start in the C10 row, when o wanted to start pasting the information on the C2.

Can you help me?

Thank you!

Hey @andrea237

Sorry for my delayed Response :slight_smile:

The first problem i can see with your Write Cell value you are using “C1”+Counter.ToString() so it is writing in a cell address C11,c12 and so on.

So just use like “C”+Counter.ToString()

and one other thing -

if you are using RowIndex of Datatable as a counter then keep in mind it will always get start from index 0 so you have to increase your counter value on each iteration by 2 :slight_smile:( because one for making address to take and one to skip to write in header cell :slight_smile: )