jardenp
Active Member
- Joined
- May 12, 2009
- Messages
- 373
- Office Version
- 2019
- 2016
- 2013
- 2011
- 2010
- Platform
- Windows
I keep a master sheet of transaction data in Master.xlsx. Column A is the unique identifier. I regularly pull new transaction data that I want to append to the Master list. The transactions in the incoming list may be totally new (new value in column A) or they may be updates of transactions already in the list. I'm trying to figure out a VBA solution to bring in the new transactions and have the updated transactions replace the older versions. This is a variation of removing duplicates, but that function (as far as I know) always keeps the duplicate with the lowest row number (i.e., topmost on the spreadsheet). Row number is irrelevant, so I'm not asking for a solution that would necessarily keep the same row order.
As an example:
Master:
[TABLE="class: grid, width: 200"]
<tbody>[TR]
[TD]Trans#[/TD]
[TD]Data1[/TD]
[TD]Data2[/TD]
[/TR]
[TR]
[TD]U100[/TD]
[TD]A[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]U101[/TD]
[TD]A[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]U102[/TD]
[TD]A[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]U103[/TD]
[TD]A[/TD]
[TD]A[/TD]
[/TR]
</tbody>[/TABLE]
Then bring in A2:C4 of the current sheet. A2:C4 is:
[TABLE="class: grid, width: 200"]
<tbody>[TR]
[TD]U104[/TD]
[TD]B[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]U105[/TD]
[TD]B[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]U101[/TD]
[TD]B[/TD]
[TD]B[/TD]
[/TR]
</tbody>[/TABLE]
This would leave Master.xlsx as:
[TABLE="class: grid, width: 200"]
<tbody>[TR]
[TD]Trans#[/TD]
[TD]Data1[/TD]
[TD]Data2[/TD]
[/TR]
[TR]
[TD]U100[/TD]
[TD]A[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]U102[/TD]
[TD]A[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]U103[/TD]
[TD]A[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]U104[/TD]
[TD]B[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]U105[/TD]
[TD]B[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]U101[/TD]
[TD]B[/TD]
[TD]B[/TD]
[/TR]
</tbody>[/TABLE]
(or if order was preserved (which it doesn't need to be)):
[TABLE="class: grid, width: 200"]
<tbody>[TR]
[TD]Trans#[/TD]
[TD]Data1[/TD]
[TD]Data2[/TD]
[/TR]
[TR]
[TD]U100[/TD]
[TD]A[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]U101[/TD]
[TD]B[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]U102[/TD]
[TD]A[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]U103[/TD]
[TD]A[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]U104[/TD]
[TD]B[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]U105[/TD]
[TD]B[/TD]
[TD]B[/TD]
[/TR]
</tbody>[/TABLE]
Please help! Is there such a thing as Remove Duplicates that starts at the bottom and looks up?
There is no time stamp or other data point I can sort by to put the most recent transaction version on top.
I know I could add a column that brought in the "uploading" time and sort by that, but I'd prefer a more elegant solution and one that doesn't require changing the data set. If I need to, I'll do that, but I know from repeated experience that this is the place for solid Excel/VBA genius.
Thanks!
JP in IN
As an example:
Master:
[TABLE="class: grid, width: 200"]
<tbody>[TR]
[TD]Trans#[/TD]
[TD]Data1[/TD]
[TD]Data2[/TD]
[/TR]
[TR]
[TD]U100[/TD]
[TD]A[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]U101[/TD]
[TD]A[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]U102[/TD]
[TD]A[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]U103[/TD]
[TD]A[/TD]
[TD]A[/TD]
[/TR]
</tbody>[/TABLE]
Then bring in A2:C4 of the current sheet. A2:C4 is:
[TABLE="class: grid, width: 200"]
<tbody>[TR]
[TD]U104[/TD]
[TD]B[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]U105[/TD]
[TD]B[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]U101[/TD]
[TD]B[/TD]
[TD]B[/TD]
[/TR]
</tbody>[/TABLE]
This would leave Master.xlsx as:
[TABLE="class: grid, width: 200"]
<tbody>[TR]
[TD]Trans#[/TD]
[TD]Data1[/TD]
[TD]Data2[/TD]
[/TR]
[TR]
[TD]U100[/TD]
[TD]A[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]U102[/TD]
[TD]A[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]U103[/TD]
[TD]A[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]U104[/TD]
[TD]B[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]U105[/TD]
[TD]B[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]U101[/TD]
[TD]B[/TD]
[TD]B[/TD]
[/TR]
</tbody>[/TABLE]
(or if order was preserved (which it doesn't need to be)):
[TABLE="class: grid, width: 200"]
<tbody>[TR]
[TD]Trans#[/TD]
[TD]Data1[/TD]
[TD]Data2[/TD]
[/TR]
[TR]
[TD]U100[/TD]
[TD]A[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]U101[/TD]
[TD]B[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]U102[/TD]
[TD]A[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]U103[/TD]
[TD]A[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]U104[/TD]
[TD]B[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]U105[/TD]
[TD]B[/TD]
[TD]B[/TD]
[/TR]
</tbody>[/TABLE]
Please help! Is there such a thing as Remove Duplicates that starts at the bottom and looks up?
There is no time stamp or other data point I can sort by to put the most recent transaction version on top.
I know I could add a column that brought in the "uploading" time and sort by that, but I'd prefer a more elegant solution and one that doesn't require changing the data set. If I need to, I'll do that, but I know from repeated experience that this is the place for solid Excel/VBA genius.
Thanks!
JP in IN