+ Reply to Thread
Results 1 to 6 of 6

How to compare two columns and highlight and rows containing duplicates

  1. #1
    Forum Contributor
    Join Date
    09-04-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    298

    How to compare two columns and highlight and rows containing duplicates

    Two columns titled "Unit1" and "Unit2" in the header row (row 1).

    These columns CANNOT be referenced by letters as they randomly change which column they are in, they must be found via text match.

    Need to compare, row by row, the values in both columns.

    If on any row, the value in the "Unit1" column = "Unit2" column, then highlight that entire row yellow.

    Dim numberofduplicaterows as integer
    set numberofduplicaterows = (the number of duplicate rows)

    if no duplicate rows found then do nothing.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: How to compare two columns and highlight and rows containing duplicates

    Here is a solution that uses conditional formatting instead of VBA, if that would be acceptable. You can move the headers around to see how the highlighting follows the Unit1 and Unit2 columns.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: How to compare two columns and highlight and rows containing duplicates

    It wasn't clear which row you wanted highlighted. This macro will highlight the row under "Unit1" where if matches "Unit2".
    Please Login or Register  to view this content.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: How to compare two columns and highlight and rows containing duplicates

    Maybe:

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    09-04-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    298

    Re: How to compare two columns and highlight and rows containing duplicates

    Quote Originally Posted by Mumps1 View Post
    It wasn't clear which row you wanted highlighted. This macro will highlight the row under "Unit1" where if matches "Unit2".
    Please Login or Register  to view this content.

    Thank you. Is it possible to modify this to do the same, but only look for duplicates in the "Unit1" column?

    I.e. if two rows in the unit1 column have the same value, highlight them both, and then at the end dim the number of duplicate rows as integer?

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: How to compare two columns and highlight and rows containing duplicates

    Hi Ks,

    Try this:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

+ 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. [SOLVED] Help Needed- Excel macro to compare two columns in two worksheets and highlight duplicates
    By advent in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-10-2013, 05:17 PM
  2. Replies: 1
    Last Post: 05-06-2013, 06:28 AM
  3. Replies: 5
    Last Post: 07-05-2011, 06:25 PM
  4. macro to compare columns and highlight common rows
    By jagman1990 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-22-2010, 12:27 PM
  5. Compare last 3 words in each row and highlight duplicates?
    By n666 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-03-2007, 07:14 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