+ Reply to Thread
Results 1 to 4 of 4

Macro to Remove Unique Rows.

  1. #1
    Registered User
    Join Date
    01-20-2011
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    11

    Macro to Remove Unique Rows.

    Hi.

    I have a spreadsheet that contains sales records (that are imported on a query from a database). The sale ID is in column A and should appear twice or more. There are some rows that only contain one sale ID, and these need to be removed. I've set a conditional format to highlight these, however rather then spend time deleting all these unnecessary rows, is there a macro that can identify a cell whose value only appears once in a range, and delete that entire row accordingly?

    Thanks.
    Last edited by 62deadfly; 05-16-2011 at 08:01 AM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,461

    Re: Macro to Remove Unique Rows.

    A macro could be written.

    For a definitive answer, please post a sample workbook.

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    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

    Re: Macro to Remove Unique Rows.

    Hi,

    Use a helper column and in it enter an IF formula with the same logic that you use for the cond. formats. Have the formula return the value "Delete" for the single IDs.

    Now filter the range on the word Delete and then select and delete all those rows.

    You can create a macro to do this as follows. Create a dynamic range name for your data including the new helper column which we'll assume is column 10 in the named range. Then add the following macro.

    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Registered User
    Join Date
    01-20-2011
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Macro to Remove Unique Rows.

    Thanks for that.

+ 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