+ Reply to Thread
Results 1 to 9 of 9

Conditional Formatting for another cell containing specific text

  1. #1
    Registered User
    Join Date
    01-27-2013
    Location
    New Mexico
    MS-Off Ver
    Excel 2010
    Posts
    38

    Conditional Formatting for another cell containing specific text

    Here is my issue. In the attached spreadsheet, for weekend days (saturday and sunday only), I need the corresponding cells in columns B,C,and D to be formatted as fill black. I would have no problem with this if the text in column A was only saturday or sunday, but because there are other words in the cell, it seems to mess with the formula. If someone could even tell me what the operator is for "contains" instead of =, so that I could put it in the formula, that would fix my problem. Any help would be appreciated.
    Attached Files Attached Files

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: Conditional Formatting for another cell containing specific text

    Hi dropanddrive, and welcome to the forum

    Actually looking for any "day" name would not work for you there, because the cell entries are dates, whis is a special form of number/value. So the cells cont actually contain "Saturday" or "Sunday", they are just formatted to look like they do

    1. highlight the range you want to apply the conditional formatting to
    2. on the home tab, styles, select CF
    3. select new rule, select use formula
    4. enter =WEEKDAY($A5,2)>5 format fill as required.

    Hope that helped?

    If the cells actually did contain text, and 1 of the words was Saturday, you could use something like this to test for it...
    =ISNUMBER(SEARCH("Saturday",A5,1))
    Last edited by FDibbins; 01-27-2013 at 02:18 AM.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Conditional Formatting for another cell containing specific text

    Try this in CF of B5 :
    =OR(WEEKDAY($A5)=7,WEEKDAY($A5)=1)
    set to all cells in range
    Quang PT

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: Conditional Formatting for another cell containing specific text

    @ bebo, if you set up the weekday() function using ,2, you can simplify the test to what I suggested in #2

  5. #5
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Conditional Formatting for another cell containing specific text

    Yep that 's a good tip. If printing out, we can save a lot of ink...
    Anyway, I've watched carefully to make sure that you were not around here before posting...

  6. #6
    Registered User
    Join Date
    01-27-2013
    Location
    New Mexico
    MS-Off Ver
    Excel 2010
    Posts
    38

    Re: Conditional Formatting for another cell containing specific text

    That is very helpful in the sense of the concept, I wasn't aware of how excel viewed the dates. However, I copied an pasted that formula into the CF formula bar to no avail. What is the function of the ($A5,2)?

  7. #7
    Registered User
    Join Date
    01-27-2013
    Location
    New Mexico
    MS-Off Ver
    Excel 2010
    Posts
    38

    Re: Conditional Formatting for another cell containing specific text

    Quote Originally Posted by dropanddrive03 View Post
    That is very helpful in the sense of the concept, I wasn't aware of how excel viewed the dates. However, I copied an pasted that formula into the CF formula bar to no avail. What is the function of the ($A5,2)?
    Lol. Oops. Had a very dumb moment. Thank you both very much for your help. Thanks given!

  8. #8
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: Conditional Formatting for another cell containing specific text

    Make sure you high-light the entire range A5:D35 (or B5:D35 if you still want the dates shown) before you go into CF

    then make sure you select USE FORMULA and either type exactly, or copy paste my formula into the CF formula bar.

    to explain the formula =WEEKDAY($A5,2)>5...

    =weekday($A5,2) is checking A5 to see what day of the week it is. there are a few arguments that come with this function, using ,2 sets Monday as 1 and Sunday as 7. This lets me then test for any weekday number >5...Sat=6, Sun=7
    the $ is absoluting column A so that it will always be the column referenced

    If you still have a problem, let me know and I will upload your (modified) file for you

  9. #9
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: Conditional Formatting for another cell containing specific text

    Happy to help, and thanks for the feedback

+ 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