Link to home
Start Free TrialLog in
Avatar of Lawrence Salvucci
Lawrence SalvucciFlag for United States of America

asked on

Delete Duplicate Rows in Excel

I need some help creating a function to delete duplicate rows in my excel worksheet. My data starts in row 24 with the headers in row 23. I need to look in column J and if it finds duplicated values I need it to delete all the duplicates but leave the first instance there. But before it deletes these duplicate rows I need it to sum up the values in column W & column G for those duplicated rows and add it to the value in the first instance in column W & column G. I've attached a sample file.
Sample-File.xlsx
Avatar of Saqib Husain
Saqib Husain
Flag of Pakistan image

The easiest way is to go for a pivot table. Write back if you need detail instructions.
ASKER CERTIFIED SOLUTION
Avatar of Wim_Bl
Wim_Bl
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Lawrence Salvucci

ASKER

Doesn't seem to work. I run the macro and it saves the file into the folder mentioned in the code below but there are no changes that I can see. And can you tell me what this code is for:

    ChDir "D:\Temp"
    ActiveWorkbook.SaveAs Filename:="C:\Temp\Sample-File.xls", FileFormat:= _
        xlExcel8, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
        , CreateBackup:=False

Open in new window

Sorry if that wasn't clear, but you should run the macro named ParseRows(). The one you run (named Macro1) was added somewhere in the save process and should be discarded.
Please give it another try and let me know if it's alright this time.

Best regards
Got it! So if I just change the value in this line of code it'll go to the end row of my choosing? Can I just set that to like row 10000 even though my rows only may go to 5000? I want to max it out so I don't have to worry about anything since the # of rows may change.

endRow = 39

Open in new window

That is completely correct. I only used these variables as a quick test. If you want to do it correctly, make sure that either you pick a number large enough, or else build in some logic that determines the last row. Same goes for the starting row and other numbers that I may have hardcoded in the solution. Good luck!


Best regards,

Wim