+ Reply to Thread
Results 1 to 15 of 15

Highlight cells if data in 2 columns match

  1. #1
    Registered User
    Join Date
    09-04-2012
    Location
    StL
    MS-Off Ver
    Office 2016
    Posts
    24

    Highlight cells if data in 2 columns match

    Hello All,
    Please see the attached example. I'm trying to highlight cells only if 2 values in the row match 2 values in another row. If a book title/author combination matches that of another title/author combination in a different row, it would highlight. Some alternate rows will contain different titles by the same author, and some rows will have like titles by different authors...but they should not highlight.
    The only situation where highlighting would occur is if the title/author pairing appears in another row.
    I'm trying to decide if this would be a conditional formatting/highlighting rule, or if it would be a macro/vbs?
    Any help would be greatly appreciated.
    I'm using Excel 2013.
    Thanks, in advance!

    Pairing example.PNG
    Attached Files Attached Files

  2. #2
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,749

    Re: Highlight cells if data in 2 columns match

    try
    =COUNTIFS($D$2:$D$15,$D2, $E$2:$E$15,$E2)>1
    Attached Files Attached Files
    Wayne
    if my assistance has helped, and only if you wish to , there is an "* Add Reputation" on the left hand side - you can add to my reputation here

    If you have a solution to your thread - Please mark your thread solved do the following: >
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Highlight cells if data in 2 columns match

    Use a conditional format with next formula, for D2 and E2, then copy and special paste as you need
    =SUMPRODUCT(--((($D$2:$D$10 )& ($E$2:$E$10))=(D2&E2)))>1

  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: Highlight cells if data in 2 columns match

    Maybe:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-04-2012
    Location
    StL
    MS-Off Ver
    Office 2016
    Posts
    24

    Re: Highlight cells if data in 2 columns match

    Thanks for the responses!
    @eTaf: Your formatting rule works, but it's missing cells at random. I don't know what's triggering them, but they remain unhighlighted even though they have a match.
    @PCI: Thanks, but this isn't really ideal to copy and paste as I am working with roughly 30k rows.
    @John: Your vba starts working, then locks up Excel. It freezes and I have to force it closed.

    I'm still taking suggestions.

  6. #6
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,749

    Re: Highlight cells if data in 2 columns match

    Your formatting rule works, but it's missing cells at random. I don't know what's triggering them, but they remain unhighlighted even though they have a match.
    I doubt its a random thing - there will be a difference
    one may be spaces or hidden characters
    Often there is a space at the end of some of the text and of course
    TEXT....[space] is different to TEXT....[nospace]

    check and see if that maybe the issue - or can you post a sample that is not working here - so we can see

  7. #7
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Highlight cells if data in 2 columns match

    "this isn't really ideal to copy and paste as I am working with roughly 30k rows"
    High light the 2 first cells and do the copy (Control + c)
    Press Shift and Control + Down arrow
    you will cover the complete column
    then do the special paste FORMAT
    Last edited by PCI; 05-27-2014 at 05:09 PM. Reason: Complement info added

  8. #8
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,749

    Re: Highlight cells if data in 2 columns match

    done, see attached
    works OK for that file
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    09-04-2012
    Location
    StL
    MS-Off Ver
    Office 2016
    Posts
    24

    Re: Highlight cells if data in 2 columns match

    @etaf: Here's a sampling.

    Edit: Oops. Didn't see your responses before I posted.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    09-04-2012
    Location
    StL
    MS-Off Ver
    Office 2016
    Posts
    24

    Re: Highlight cells if data in 2 columns match

    @PCI: Thanks, I'm tinkering more with your suggestion. I totally forgot that I could paste the formatting apart from the values. DUH! Sorry.

  11. #11
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,749

    Re: Highlight cells if data in 2 columns match

    the apply range is
    =$D$2:$E$4,$D$6:$E$9,$D$11:$E$17,$D$19:$E$19,$D$21:$E$1016959
    so missing some rows

    try using
    =COUNTIFS($D:$D,$D1,$E:$E,$E1)>1
    and apply to
    =$D:$E

    see sample below
    Attached Files Attached Files

  12. #12
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Highlight cells if data in 2 columns match

    I could be more clear and updated the answer: Special Paste FORMAT

  13. #13
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,749

    Re: Highlight cells if data in 2 columns match

    I could be more clear and updated the answer: Special Paste FORMAT
    sorry, I have since seen the issue in your sample and replied with a fix

    is the original still an issue if you delete all the conditional formatting and just use the new formula and apply range ?

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

    Re: Highlight cells if data in 2 columns match

    Quote Originally Posted by damobilebrood View Post
    Thanks for the responses!
    @eTaf: Your formatting rule works, but it's missing cells at random. I don't know what's triggering them, but they remain unhighlighted even though they have a match.
    @PCI: Thanks, but this isn't really ideal to copy and paste as I am working with roughly 30k rows.
    @John: Your vba starts working, then locks up Excel. It freezes and I have to force it closed.

    I'm still taking suggestions.

    Worked when I tested it on your sample:

    Try:

    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    09-04-2012
    Location
    StL
    MS-Off Ver
    Office 2016
    Posts
    24

    Re: Highlight cells if data in 2 columns match

    Sorry for the late response. I'm back at it.
    @etaf: The range was showing weird values because I just took a sampling from my actual sheet. Like I said, I have about 30,000 rows. When I clipped the rows for the sample it adjusted the range shown in the formula. In the original sheet, the range is D2 to D28,200 and E2 to E28,200.
    @John: I do see your VBA start to work, but then crash. I honestly think it's because of the size of the sheet that it hangs.

    I managed to get the desired results, though, by using a combination of your suggestions.
    Thank you so much for taking the time to reply! It is much appreciated!
    Last edited by damobilebrood; 05-28-2014 at 09:22 AM.

+ 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. highlight if cells DONT MATCH
    By happydaize in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-27-2014, 07:35 PM
  2. [SOLVED] compare values in two cells, highlight when there is no match.
    By frhling in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 01-03-2013, 09:29 AM
  3. Replies: 3
    Last Post: 05-18-2012, 08:11 AM
  4. Highlight the cells that match??
    By Ltat42a in forum Excel General
    Replies: 8
    Last Post: 08-26-2011, 12:36 PM
  5. Match data in 2 Worksheets and highlight columns
    By JimmiOO in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-16-2010, 08:47 AM

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