+ Reply to Thread
Results 1 to 4 of 4

Change color of cell depending on character in string

  1. #1
    Registered User
    Join Date
    10-17-2008
    Location
    US
    Posts
    35

    Change color of cell depending on character in string

    I have a string of characters in Column D which will look like so:

    ==MTWRF
    ==MTWR=
    Y=MT=RF
    ==MTW=F
    Y=MT=RF

    The = represents a day off.
    Columns F thru L are labelled With days of the week (starting w/ Sat)

    F=Sat
    G=Sun
    H=Mon
    I=Tues
    J=Wed
    K=Thurs
    L=Fri

    I would like to shade the corresponding cell black where the = sign represents a day.

    ==MTWRF would shade F (Sat) and G (Sun)
    ==MTWR= would shade F (Sat), G (Sun) and L (Fri)

    It seems I should be able to use conditional formatting, but I am not certain what formula to use.

    Thanks for any help you can provide (I can attach the spreadsheet if that would make it simpler)

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Change color of cell depending on character in string

    Assuming you are starting in F2, select F2:M(last row) and go to Format|Conditional Formatting... choose Formula Is and enter formula:

    =IF(MID($D2,COLUMNS($F$1:F$1),1)="=",1,2)

    then click Format and choose from Pattern Tab.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    10-17-2008
    Location
    US
    Posts
    35

    Re: Change color of cell depending on character in string

    Quote Originally Posted by NBVC View Post
    Assuming you are starting in F2, select F2:M(last row) and go to Format|Conditional Formatting... choose Formula Is and enter formula:

    =IF(MID($D2,COLUMNS($F$1:F$1),1)="=",1,2)

    then click Format and choose from Pattern Tab.
    I simplified it somewhat ... =MID(D4,1,1)="=" and it seems to work.

    thanks so much.

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Change color of cell depending on character in string

    You are correct, it should have been simplified...

    I had done a test in a cell with a regular formula and copied that instead of the one I had in the conditional formula:

    =MID($D2,COLUMNS($F$1:F$1),1)="="

    Note, though that the COLUMNS($F$1:F$1) is what allows for the formula to "adjust" to next character in the original string in column D. Also you need the $ before the D to keep an absolute reference to column D

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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