Results 1 to 3 of 3

Thread: [RESOLVED] Simple duplicate eliminating script

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2006
    Posts
    41

    Resolved [RESOLVED] Simple duplicate eliminating script

    Hey all, kinda new to the whole vba thing.

    I'm trying to do something fairly simple: I have a couple hundred lines of data in a spreadsheet, and there are duplicates from when i complied all the data together. I've sorted the list alpha by company name. I'm trying to write a simple script that checks column B (the name of the company) against the following row to see if it's a duplicate; if it is delete the entire row, and then recheck (because there can be 3-4 duplicate entries), if it's not a duplicate move onto the next row.

    Thanks a bunch guys, i'm just having trouble finding a good resource for vba online.
    Last edited by heinz1218; Jul 17th, 2006 at 03:49 PM. Reason: resolved

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Simple duplicate eliminating script

    how about this:

    VB Code:
    1. Private Sub RemDups()
    2.     Dim ROW As Integer
    3.     ROW = 1
    4.     Do Until Range("B" & ROW) = ""
    5.         Range("B" & ROW).Select
    6.         If Range("B" & ROW) = Range("B" & ROW + 1) Then
    7.             Rows(ROW & ":" & ROW).Delete Shift:=xlUp
    8.         Else
    9.             ROW = ROW + 1
    10.         End If
    11.     Loop
    12. End Sub
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3

    Thread Starter
    Member
    Join Date
    Jul 2006
    Posts
    41

    Resolved Re: Simple duplicate eliminating script

    Thanks a bunch, Static, that worked great. Just out of curiousity, why'd you make it a Private? I couldn't see it in my macro list until i removed the private attribute.

    Thanks again
    Last edited by heinz1218; Jul 17th, 2006 at 04:09 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width