+ Reply to Thread
Results 1 to 5 of 5

Highlight Cells Containing Duplicate Document Codes In Commaed Lists

  1. #1
    Registered User
    Join Date
    06-05-2008
    Posts
    3

    Highlight Cells Containing Duplicate Document Codes In Commaed Lists

    I've been trying to find how to mark duplicate product codes. The excel file is for recording document changes. Each row contains the data relavent to the change. One column represents the documents affected by the change. The documents all have differen't naming standards and are listed in the cell like this "XHD89d, 88-0345b, NO45.KDg". The last letter represents the revision of the document. I'm wanting excel to flag cells if one of the document codes is the same as in another cell within the column. Ie one cell contains "45-9930j, FF55.JKb" and another "45-9930j, 33-0989h" so the cells would be highlighted indicating that another person has associated that document revision with their change. This is to avoid two people working on the same document at once. Once the change has been approved the document revision is updated so the next person wouldn't input the same value, ie 45-9930j -> 45-9930k. I've found some things about looking at each cell but not if the cell contains some comma separted list. Any ideas?

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967
    Select the range of interest and run this macro. Paste the code into a new module in the VBA editor (ALT F11)

    Please Login or Register  to view this content.
    Any cells containing duplicates will be highlighted in red.

  3. #3
    Registered User
    Join Date
    06-05-2008
    Posts
    3
    Thanks that's what I was looking for.
    Though it needs to check both cells with comma separated items and ones with only one item, ie no commas. Also I'd like this to run anytime a cell in the particular column is changed. I tried figuring this out with worksheet events and something that would select cells 1-99999 in a particular column but I couldn't figure it out. The macro seemed to crash if I selected the whole column I assume because that's infinite # of cells or something like that.

  4. #4
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967
    The code should work for any mixture of cells containing comma or not.

    The reason for your 'crash' with the whole column is that the macro compares every cell with every other cell to look for duplicates and therefore the length of time taken to run the code is roughly proportional to the square of the number of cells selected. Selecting the whole column means a lot of redundant activity.

    It would be possible to produce a slightly more sophisticated version which selected only the filled cells within the range which would get around such an issue.

  5. #5
    Registered User
    Join Date
    06-05-2008
    Posts
    3
    This is the code I've come up with that works fairly well. It's a little redundant and messy. I'm try to take into account different combinations of commas and spaces that people might use. The only thing I'm running into is the use of Alt-Enter. Some people do this to have the log files look nice especially with hyphenated numbers so they don't split between lines. How would I make this code ignore their use when separating the numbers into the arrays for comparison? Right now the code with flag say "8Alt-Enter9" only with "8Alt-Enter9" not lines that are even just 8 or 9. I tried something with CHAR(10) but no luck. Any pointers on cleaning up the code would be greatly appreciated too.

    Please Login or Register  to view this content.
    Last edited by C.Perrin; 06-10-2008 at 03:17 PM.

+ 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. Merging Cells With Duplicate Values
    By BluTalon in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-28-2011, 09:52 PM
  2. DropDown Lists in Cells
    By TREBORA in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 05-14-2008, 12:27 AM
  3. searching for duplicate cells
    By Holly in forum Excel General
    Replies: 1
    Last Post: 07-06-2007, 11:05 AM
  4. Comparing Lists - F2 - Format Cells
    By sachinattri in forum Excel General
    Replies: 7
    Last Post: 11-03-2006, 02:29 AM
  5. Highlight cells as cursor passes over them
    By mrdata in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-01-2006, 06:56 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