Write cell in for each loop

Hello, everyone!
I got some problem which is I can’t write data at the last row of excel file in For Each Loop, so I want to start writing from the last row.
Please help

Regards, Temuulen

Hi @Temuulen_Buyangerel ,
I think write cell in loop, you can use index,
add to index +1 after each loop
Can you share your input and expected results?
Regards,
LNV

Hey,
Sorry, I can’t upload any image or files.
I think I should Read excel file to datatable and count rows of it, after that use write cell but it’s not working.
RowCount=DatatableofExcel.Rows.Count.ToString
In Write Cell:
Input: “abc”
Where to write : Excel.Sheet(“Stage-1”).Cell(“D”+RowCount)

@Temuulen_Buyangerel

do you wanted to append the data or else write the data in a specific column?

Regards

Hi,
You can try my step


add 1 to index after each loop
Hope it help

I want to append data on it

I think it doesn’t starts from 1.

@Temuulen_Buyangerel

Initialize the count value with 2 so that it helps in writing the data after the existing data table.

"D"+(RowsCount+Count).ToString

Logic for write cell value.

Here I uploaded xaml for your reference.
sample.xaml (188.0 KB)

Hope it helps!!

1 Like

that’s my example, 1 because excel starts with 1
you can customize according to your file
it can get index after a certain text, depends on your requirement

1 Like

Mine is like count of rows is unknown so it works on new excel file.
Thank you.

It works!
Thank you, I appreciate it.

@Temuulen_Buyangerel

Thank You

Happy Automation!!

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