+ Reply to Thread
Results 1 to 6 of 6

Deleting Duplicate rows...VBA Code

  1. #1
    Registered User
    Join Date
    05-24-2008
    Posts
    4

    Deleting Duplicate rows...VBA Code

    I have found a bit of code that deletes duplicates and keeps rows based on the the highest value in column B.

    BM411757 1
    BM411757 2
    BM411757 3

    So the results of below code would be:

    BM411757 3

    however I am looking for something that would delete the row with the higest value. Result would be:

    BM411757 1
    BM411757 2

    I haven't been able to adjust this code to work this out. Could someone help with this. Many thanks in advance.

    Rob

    Please Login or Register  to view this content.
    Last edited by VBA Noob; 05-24-2008 at 10:50 AM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    Hi,

    Try the following modified code.

    HTH

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    05-24-2008
    Posts
    4
    Hi Richard,

    Thanks for your response.

    I have tried this. It works well when there is 2 or 3 duplicates but when there are 4 or 5 duplicates it deletes the 2nd and 3rd row respectively instead of the 4th or 5th.

    example for when there is 4 duplicates:

    BM411757 1
    BM411757 3


    and for 5 duplicates:

    BM411757 1
    BM411757 2
    BM411757 4


    Many thanks
    Rob

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    Hi Rob,

    Try this variation

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-24-2008
    Posts
    4
    thats great thanks Richard

  6. #6
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    robkozak,

    Please read forum rules below. Cross posting on other forums without the link is not permitted

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1