ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   On Duplicate, update record (https://www.excelbanter.com/excel-discussion-misc-queries/226493-duplicate-update-record.html)

MikeD1224

On Duplicate, update record
 
I have a table of data that has 4 columns:

Column A : Transaction Date
Column B: Prescription #
Column C: Date of Service
Column D: Amount Due

Using Column A, B & C I can identify unique records.

The file is organized chronologically by Transaction Date (column A).

I am trying to find a method by which I can write a macro or script to go
through the file and upon finding a duplicate record, remove all but the last
instance/occurrence.

Any help/ideas would be much appreciated.

Mike

Dave Peterson

On Duplicate, update record
 
I would insert a new column E.

I'd put this in E2 (headers in row 1, right?)

=text(a2,"mm-dd-yyyy")&"."&b2&text(c2,"mm-dd-yyyy")
and drag down as far as I needed.

Then in F2 (another helper column):
=IF(COUNTIF($E$2:E2,E2)=COUNTIF(E:E,E2),"keepme"," delete me")
and drag down.

Then filter column F to show the deleteme's (after you do some minor checking).

And then delete the visible rows.

Then remove the filter and delete the two helper columns.

=======
If I needed a macro, I would do the same thing, but in code. In fact, I'd
record a macro when I did it manually to help build the code.



MikeD1224 wrote:

I have a table of data that has 4 columns:

Column A : Transaction Date
Column B: Prescription #
Column C: Date of Service
Column D: Amount Due

Using Column A, B & C I can identify unique records.

The file is organized chronologically by Transaction Date (column A).

I am trying to find a method by which I can write a macro or script to go
through the file and upon finding a duplicate record, remove all but the last
instance/occurrence.

Any help/ideas would be much appreciated.

Mike


--

Dave Peterson


All times are GMT +1. The time now is 03:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com