CALCULATING VALUES OF COLUMN A AND COLUMN B AND WRITING TO COLUMN C USING WRITE CELL

Hi all,sample

Hi all,
I read data from Sample Columns.xlsx file and stored into outputDT DataTable (which has Columns A and B)

Then I want to add values of Columns A and B and write it to Column C in the same Input Excel file(Sample Columns.xlsx)

For that I’m using Write Cell Activiyt to write in Column C (cint(row(0))+cint(row(1))) .

But I’m not getting result in Column C instead I’m getting 3668 value in all rows of Column C.

Can anyone help me please
Thanks In Advance.

)

Hi @saritha
Would you mind sending the samples ?

You need to change the range in the Write Cell activity to be cell specific. For row 1, it should be “C1”. For row two, it should be “C2” and etc.

One way to achieve this is to assign an Int32 variable to the Index property of the For Each Row. Then you can set the range to "C" + (Index+1).ToString

image

image

2 Likes

hibnm

Hi,
Thank you for ur reply.
But When I try ur code using Index , output is printing in wrong cell.
Can u please help me

Then try to put “C” + (index+2).tostring, it may regulate the rows

Could you show us a screenshot of the Write Cell Range property? It doesn’t like it has added the +1.

When Tried with( index+2) to regulate the rows.

First c1 column is going wrong.


Thanks for ur help.

sample3

What are your options with headers in the read and the write range ?
Read range should not add headers, same goes with write range.
Try to remove the 3rd column and give it a try again

2 Likes

Just unchecked the Add Headers . now every thing came perfect columns.
and used “C” + (Index+1).ToString in Range(or cell) place for write cell Activity.

And May I know what will be the index value for the first time.

Thanks for ur reply

1 Like

Hi @saritha

Try the below code using invoke code activity with outputDT as In/Out argument

outputDT.AsEnumerable().ToList().ForEach(row(2)=CInt(row(0))+CInt(row(1)))

Then use write range (with add headers option being checked) to write the outputDT

Regards,

Nived N

Happy Automation

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