Update a cell in looped row

excel
activities

#1

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?

image


#2

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.

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

Thanks


#3

Hi,
picture talks louder than words. :smiley:

status


Update the data in every row in csv
#4

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.


#5

Assigne the counter to default 1.


#6

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


#7

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.


#8

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


#9

is it “a”+cnt.Tostring?


#10

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:

Regards…!!
Aksh


#11

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.

Thanks


#12

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

Regards.>!!
Aksh


#13

Thanks,

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


#14

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

Regards…!!
Aksh


#15

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


#16

Hey @Snehal1

May i know what kind of error you are facing?

Regards…!!
Aksh


#17

Hi,

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)

Capture


#18

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.