Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting duplicate rows in Excel using VBA 1

Status
Not open for further replies.

gal4y

Technical User
Dec 24, 2001
72
US
I have a 1000 entries of students from several different databases. Before I put them into my own database, I would like to delete duplicate rows. The columns consist of last name (first column), first name (2nd), SSN (3rd), etc.

Is there a way to write a short program to go through and delete the duplicate rows. I can see the duplicate rows from the sort I did.

Thanks for any help.

Greg
 
Greg,

The "quick and easy" way...

1) Highlight the range of data by: a) Go to the cell with "LastName", b) Hold down the "Shift" key, c) Hit the "End" key, followed by the "Down" arrow, d) Hit "Right Arrow" twice. e) Now release the "Shift" key.

2) From Excel's menu, choose: "Data" - "Filter" - "Advanced Filter".

3) From the "Advanced Filter" window, click on "Unique records only" (lower-left-corner)

4) Click "OK"

5) Copy the &quot;condensed&quot; range - Use <Control> C

6) Go to a separate sheet and &quot;Paste&quot; the data - Use <Control V

You now have a set of &quot;Unique&quot; records.

If you prefer to copy the data back to the original sheet, first appreciate that the original sheet STILL has the &quot;complete&quot; data - with the &quot;duplicate record rows&quot; hidden.

Therefore, you will FIRST have to go back and highlight the &quot;condensed data&quot;, and use &quot;Data&quot; - &quot;Filter&quot; - &quot;Show All&quot;
Actually, the data will still be highlighted from your copy/paste, so you can just go ahead and use &quot;Data&quot; - &quot;Filter&quot; - &quot;Show All&quot;.

Then, delete all the original data.

Then, copy the set of &quot;Unique&quot; records back to the &quot;original sheet&quot;.

I hope this is understandable, and &quot;quick enough&quot;.

Please advise as to how you make out.

Regards, ...Dale Watson dwatson@bsi.gov.mb.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top