+ Reply to Thread
Results 1 to 10 of 10

How to highlight cell on column A if they include any of the strings on column B?

  1. #1
    Forum Contributor
    Join Date
    05-10-2011
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    145

    How to highlight cell on column A if they include any of the strings on column B?

    Hello everyone,
    Please see excel file attached.
    I have a simple question:
    As you can see on the file attached, I have only 2 columns in the worksheet, Column A and column B, they both contain simple strings (words).
    I would like to highlight all cells on column A that contain ANY of the strings on column B.

    I prefer a macro based solution but if its much easier with a formula - that might work for me as well.

    Many thanks,


    Sami
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: How to highlight cell on column A if they include any of the strings on column B?

    This formula in conditional formatting:
    =SUMPRODUCT(--NOT(ISERROR(SEARCH($C$1:$C$59,A1))))

    Note I've referenced column C as column B entries have trailing spaces which will cause null result, C2=trim(B2)
    CC


    If you feel really indebted please consider a donation to charity. My preferred charity is ActionAid but there are plenty of worthy alternatives.

  3. #3
    Forum Contributor
    Join Date
    05-10-2011
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    145

    Re: How to highlight cell on column A if they include any of the strings on column B?

    Thanks for the fast response!
    I did exactly what you suggest (see file attached) but it did not highlight the cells on column A
    Did I miss something?

    Sami

    Quote Originally Posted by Cheeky Charlie View Post
    This formula in conditional formatting:
    =SUMPRODUCT(--NOT(ISERROR(SEARCH($C$1:$C$59,A1))))

    Note I've referenced column C as column B entries have trailing spaces which will cause null result, C2=trim(B2)
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: How to highlight cell on column A if they include any of the strings on column B?

    When I look at the formula in the conditional formatting at A1 I find:
    =SUMPRODUCT(--NOT(ISERROR(SEARCH($C$1:$C$59,A1040509))))

    1040509??!!

    Select the whole column (click the A) and reapply the formatting with A1.

    'Applies to' can be $A:$A (rather than include numbers giving an arbitrary limit)

  5. #5
    Forum Contributor
    Join Date
    05-10-2011
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    145

    Re: How to highlight cell on column A if they include any of the strings on column B?

    Thank you!
    Quote Originally Posted by Cheeky Charlie View Post
    When I look at the formula in the conditional formatting at A1 I find:
    =SUMPRODUCT(--NOT(ISERROR(SEARCH($C$1:$C$59,A1040509))))

    1040509??!!

    Select the whole column (click the A) and reapply the formatting with A1.

    'Applies to' can be $A:$A (rather than include numbers giving an arbitrary limit)

  6. #6
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: How to highlight cell on column A if they include any of the strings on column B?

    Hi ,

    use this code to get your job done. Also you need to fill the cell "C1" with a color that you will use to highlight the cells that match our search.

    Hope this helps.

    Happy Computing.


    Please Login or Register  to view this content.
    Last edited by xlbiznes; 02-22-2013 at 09:13 AM.

  7. #7
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: How to highlight cell on column A if they include any of the strings on column B?

    xlbus,
    Please use code tags with your code. You can edit the above code by: Edit-Highlight the entire code, choose # from the quick reply menu

  8. #8
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: How to highlight cell on column A if they include any of the strings on column B?

    noted, changed and thank you for letting me know.

  9. #9
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: How to highlight cell on column A if they include any of the strings on column B?

    xlbus,
    You have "me" in your code. Is the OP supposed to put the code on sheet1, not on the standard module?

  10. #10
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: How to highlight cell on column A if they include any of the strings on column B?

    AB33,
    You need to paste this code on the code behind for sheet1.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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