I want to append two datatables by columns and not rows in Excel

I don’t really know how to explain or word it properly what I’m trying to do. However, I’ll do my best to properly word it so you guys can understand. I have two worksheets that I want to combine in one worksheet. I tried merge, join data table and append range but they didn’t satisfy what I was trying to do.

I have two excel sheets that I want to combine in one sheet. I’ll show an example image below and what output I’m trying to achieve.

I hope this is clear and thank you in advance

Hi @kevzki
Welcome to the UiPath community!

Fundamentally speaking, the tables you are expecting to join column-wise, don’t have any common columns between them. That is the reason these table activities haven’t worked well.
If the robot were to join or merge the tables, what would be the reference to decide which row matches which?
If the sequence is already taken care of and all you want to do is just append the second table to the right of the first, you might want to use Append Range from cell “D3
If you’re unsure how many columns the first table will have, then write some logic to find the next empty cell. Here is a forum thread to help you with that.

Note: This is just ONE way to achieve this. There is probably a better, more efficient way to do this. I share this approach so you may find use for it in your solution.

Hello, thank you very much for the answer. Yes, you are correct, I just want to append the second table to the right. I like the solution that you tried giving me. However, you mentioned that I can use Append Range from the cell that I like. May I know how can I do this? I tried checking both Append Range activities and I don’t see any cell or range properties in it. Can you help me or enlighten me about this, thank you again :slight_smile:

You should use “write range” rather than the “append range” activity. Your main task is to determine which column you want to write your new range. This can be done in 2 parts.

Part 1 = count how many columns exist in the first datatable (dt1.columns.count) - it looks like you want a space between, so add 1 to the end of this.

Part 2 = convert the number into a letter since that’s how excel likes it. You can use this snippet to do so: Excel Index to Column - RPA Component | UiPath Marketplace

Now in your write range just write the table to start at column pulled from part 2, row 1 (e.g. “E1” in your screenshot example)

2 Likes

Thanks, this make sense a lot.

1 Like

I stand corrected. Write Range is the right one to use here.
Thanks @Dave for sharing the connect component. :slight_smile:

Regards.

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