+ Reply to Thread
Results 1 to 7 of 7

Clear (not Delete) Duplicate Values in Column

  1. #1
    Registered User
    Join Date
    10-22-2010
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    15

    Clear (not Delete) Duplicate Values in Column

    I feel stupid asking this question - it should be easy but I keep getting a "variable required - can't assign to this expression" error.

    I'm trying to evaluate cells in column B. If the value in cell B3 is the same as the value in B2, clear the value in A3 and B3. If the value in cell B4 is the same as B3, clear A4 and B4, and so on until the last cell of the range. Here is what I came up with:

    Please Login or Register  to view this content.
    I've attached a file that has the original data in one worksheet (source), then the desired result in another (result).

    Thanks for any guidance you can provide.
    Attached Files Attached Files
    Last edited by cda; 12-14-2010 at 12:05 PM.

  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
    49,024

    Re: Clear (not Delete) Duplicate Values in Column

    I'd use a helper column but there are probably other/easier ways:

    In column H, starting in cell H2:

    =IF(AND(COUNTIF(B:B,B2)>1,B2<>B1),"","flag")

    Then:

    Please Login or Register  to view this content.

    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 Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Clear (not Delete) Duplicate Values in Column

    One way might be
    Please Login or Register  to view this content.

    Hope this helps
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  4. #4
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Clear (not Delete) Duplicate Values in Column

    Have changed your code a little. Better I think to start at the bottom and work up as you are deleting cells.
    Please Login or Register  to view this content.
    OK, a bit late, but I think your original error was misuse of Set, not needed if you are assigning to the value of a cell, only a range itself.

  5. #5
    Registered User
    Join Date
    12-09-2010
    Location
    Essex, England
    MS-Off Ver
    Excel 2002
    Posts
    41

    Re: Clear (not Delete) Duplicate Values in Column

    I might be clearing the wrong cells for you, but something like this?

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    12-09-2010
    Location
    Essex, England
    MS-Off Ver
    Excel 2002
    Posts
    41

    Re: Clear (not Delete) Duplicate Values in Column

    Gosh - didn't realise I typed so slowly! Or maybe you 3 guys are just lightning

  7. #7
    Registered User
    Join Date
    10-22-2010
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Clear (not Delete) Duplicate Values in Column

    Wow, you guys are fast!

    StephenR, your code worked beautifully! I'm going to dissect it to see how you did this.

    Thank you martinleyland, Marco & TMSchucks as well. I'm learning there is always more than one way to do something in VB, so I will learn from your examples as well.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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