Write cells from bottom to top help

Hello,
I have a question about writing to Excel cells.
Normally, cells are written from top to bottom, but is there a way to write cells from bottom to top?
I’m not sure how to approach this, so I’m reaching out for guidance.
Could you please provide me with the code or method for achieving this?
Thank you in advance for your response!

image

Hi,

Can you elaborate? The following is simple case, for example.

Regards,

1 Like

Hi @22222222asas

You can try below waydt:
=> Use Rad Range Workbook to read the excel and store it in an data table say dt. If it has no headers make sure to remove Add Headers option.
=> Use the below syntax in Assign activity:

dt= dt.AsEnumerable().Reverse().CopyToDataTable()

=> Use Write Range Workbook activity to write the data back to excel.
Input:


Workflow:

Output:

Hope it helps!!
Regards

1 Like

@Yoichi
Hello!
Thank you for your response!
To provide more details: Assuming the starting cell is A6, I would like the first input to go to cell A6, the second input to A5, the third input to A4, the fourth input to A3, and the final input to A2. Additionally,
when I implemented the code based on your advice, the results were as shown in the image below.
Could you suggest any alternative methods or codes for achieving this?
Thank you!

image

@mkankatala
Hello!
Thank you for your response!
To provide more details: Assuming the starting cell is A6, I would like the first input to go to cell A6, the second input to A5, the third input to A4, the fourth input to A3, and the final input to A2. Although the code you provided is excellent, it seems slightly different from what I’m looking for. Could you please share the code developed according to the description above? I apologize for any inconvenience.
Thank you!

Hi,

Can you try to set idx at Index property of ForEach activity, if you have not yet?

Regards,

1 Like

@Yoichi
Thank you for your response!
It seems to be working well.
Could you please guide me on how to adapt the code if the starting cell value is A32?
Thank you!
image

Hi,

If starting address is always A32, the following will work.

"A"+(32-idx).ToString

Regards,

1 Like

Hi @22222222asas

If you start writing from the cell A32 then follow below process:


Counter is of DataType System.Int32. In the cell value give "A" + (33 - counter).ToString()

Output:

If you want to start writing from A6 then you can do the below way:


Counter is of DataType System.Int32. In the cell value give "A" + (7 - counter).ToString()

Output:

If you want to write from any other cell just change the condition in For Each and Write Cell Workbook condition.

Hope it helps!!
Regards

1 Like

@Yoichi
Thank you for your response!
The code is working as expected.
Happy New Year!!!

1 Like

@mkankatala
Thank you for your response!
I will refer to this code and try to develop it
Happy New Year!!!

1 Like

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