+ Reply to Thread
Results 1 to 3 of 3

VBA program for identify & highlight the duplicate values

  1. #1
    Registered User
    Join Date
    01-06-2013
    Location
    India
    MS-Off Ver
    Excel 2003,2007
    Posts
    31

    VBA program for identify & highlight the duplicate values

    Hi,


    I am new to this VBA, and i was trying to highlight duplicate values through the vba. Please see below code and correct me; where i shall modify/rectify the code


    Please Login or Register  to view this content.

    Thanks in advance !

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA program for identify & highlight the duplicate values

    Hello BRout,

    Your macro will only check if a duplicate appears sequentially in the list, i.e. 1,2,3,3,3,4. There are a few ways to do this. Most involve a double loop to compare each value against all other values. While this works, it is extremely slow as the list gets bigger.

    A much better approach is save the unique values in a Collection object. The Collection object will throw an error if an item to be added already exists in the collection. The error is then the signal the data is duplicate. Collection objects use a hash method to access the members randomly. Here is your macro using a Collection object.

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: VBA program for identify & highlight the duplicate values

    Quote Originally Posted by BRout View Post
    i was trying to highlight duplicate values through the vba
    I wrote code for that some time ago. See below. Disclaimer - I wrote it some time ago and no longer use it. No idea how well it works now.

    Please Login or Register  to view this content.
    *******************************************************

    HELP WANTED! (Links to Forum threads)
    Trying to create reusable code for Custom Events at Workbook (not Application) level

    *******************************************************

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Using different colors to highlight duplicate values
    By mbonin in forum Excel General
    Replies: 3
    Last Post: 09-17-2013, 03:01 PM
  2. Highlight duplicate values
    By abibayley in forum Excel General
    Replies: 3
    Last Post: 04-23-2012, 12:03 PM
  3. Need help on how to highlight duplicate values
    By avadakedava in forum Excel General
    Replies: 3
    Last Post: 04-10-2012, 11:27 AM
  4. Highlight duplicate row values
    By Brian Tam in forum Excel General
    Replies: 5
    Last Post: 08-27-2010, 04:54 PM
  5. Replies: 3
    Last Post: 06-26-2006, 06:10 PM

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