ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   macro to delete rows below the first row with duplicate data (https://www.excelbanter.com/excel-programming/434984-macro-delete-rows-below-first-row-duplicate-data.html)

tkmaster3

macro to delete rows below the first row with duplicate data
 
I am looking for a macro to delete rows of data that are below the row I want
to keep. I have a table that pulls in scan codes from specific work order
#'s. The problem I have is that I only need to have the last scan that was
entered for that work order #, and not every scan that was done previously to
that work order #.

WO NUMBER DC TRAN DATE DC TRAN TIME
0436686 10/14/2009 0:00 1292
0436686 10/14/2009 0:00 1008
0436686 10/14/2009 0:00 979
0436686 10/14/2009 0:00 976
0436686 10/14/2009 0:00 974
0436686 10/13/2009 0:00 1597
0436686 10/13/2009 0:00 1582
0436663 10/14/2009 0:00 1275
0436663 10/14/2009 0:00 1044
0436663 10/14/2009 0:00 1008
0436659 10/13/2009 0:00 1455
0436659 10/13/2009 0:00 1448
0436659 10/13/2009 0:00 1448
0436655 10/14/2009 0:00 1380
0436655 10/13/2009 0:00 1375
0436552 10/13/2009 0:00 1560
0436552 10/13/2009 0:00 1386
0436551 10/13/2009 0:00 1560
0436551 10/13/2009 0:00 1386
0436549 10/13/2009 0:00 1561
0436549 10/13/2009 0:00 1386

The Advanced Filter of the Data tab works perfect when I select the WORK
ORDER column and select Unique records only. The problem is that they are
only hidden and the data is still there. I want to reduce the file size by
eliminating the un needed data.

Basically a macro that would only keep the first row of the duplicated work
order# is all I want to keep, and the others deleted.

Thank you,
--
~TK~

tkmaster3

macro to delete rows below the first row with duplicate data
 
I should add I am using Excel 2003

I want the data to look like this when the macro is done:
WO NUMBER DC TRAN DATE DC TRAN TIME
0436686 10/14/2009 0:00 1292
0436663 10/14/2009 0:00 1275
0436659 10/13/2009 0:00 1455
0436655 10/14/2009 0:00 1380
0436552 10/13/2009 0:00 1560
0436551 10/13/2009 0:00 1560
0436549 10/13/2009 0:00 1561

--
~TK~


"tkmaster3" wrote:

I am looking for a macro to delete rows of data that are below the row I want
to keep. I have a table that pulls in scan codes from specific work order
#'s. The problem I have is that I only need to have the last scan that was
entered for that work order #, and not every scan that was done previously to
that work order #.

WO NUMBER DC TRAN DATE DC TRAN TIME
0436686 10/14/2009 0:00 1292
0436686 10/14/2009 0:00 1008
0436686 10/14/2009 0:00 979
0436686 10/14/2009 0:00 976
0436686 10/14/2009 0:00 974
0436686 10/13/2009 0:00 1597
0436686 10/13/2009 0:00 1582
0436663 10/14/2009 0:00 1275
0436663 10/14/2009 0:00 1044
0436663 10/14/2009 0:00 1008
0436659 10/13/2009 0:00 1455
0436659 10/13/2009 0:00 1448
0436659 10/13/2009 0:00 1448
0436655 10/14/2009 0:00 1380
0436655 10/13/2009 0:00 1375
0436552 10/13/2009 0:00 1560
0436552 10/13/2009 0:00 1386
0436551 10/13/2009 0:00 1560
0436551 10/13/2009 0:00 1386
0436549 10/13/2009 0:00 1561
0436549 10/13/2009 0:00 1386

The Advanced Filter of the Data tab works perfect when I select the WORK
ORDER column and select Unique records only. The problem is that they are
only hidden and the data is still there. I want to reduce the file size by
eliminating the un needed data.

Basically a macro that would only keep the first row of the duplicated work
order# is all I want to keep, and the others deleted.

Thank you,
--
~TK~



All times are GMT +1. The time now is 08:23 AM.

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