+ Reply to Thread
Results 1 to 9 of 9

Conditional Formatting a cell from a "true/false" VLOOKUP

  1. #1
    Registered User
    Join Date
    02-01-2012
    Location
    Wales
    MS-Off Ver
    Excel 2007
    Posts
    45

    Conditional Formatting a cell from a "true/false" VLOOKUP

    I am trying to add a conditional format, to a cell using a VLOOKUP formula.
    I believe the conditional formatting works, if =TRUE
    putting this code into a cell, returns 1543
    =VLOOKUP(C5,'Sunday Duty Times'!$A$4:$N$99,3,FALSE)
    I would like to conditional format if <1600

    Could I get help with the syntax for this please.

    =VLOOKUP(C5,'Sunday Duty Times'!$A$4:$N$99,3,FALSE)<1600
    the above seems to NOT Work for me

    Thanks.

  2. #2
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Conditional Formatting a cell from a "true/false" VLOOKUP

    Works for me..

    Do this..

    - Select cell you intend to conditionally format
    - Conditionally format using new rule -- formula to determine which cells to format --
    Use this formula
    =VLOOKUP(C5,'Sunday Duty times'!$A$4:$N$99,3,FALSE)<1600

    - Format --Red
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  3. #3
    Registered User
    Join Date
    02-01-2012
    Location
    Wales
    MS-Off Ver
    Excel 2007
    Posts
    45

    Re: Conditional Formatting a cell from a "true/false" VLOOKUP

    Hmm? earlier, "im fairly sure" this formula was excepted but didn't do anything.
    But now, im getting "You cannot use references to other worksheets or workbooks for Conditional Formatting criteria"

    This VLOOKUP is a reference to another sheet, in the SAME workbook?

    just tryed without the"=" and this statment is accepted, but don't work. must be what I did earlier.

    any ideas?
    Last edited by Solidstan; 06-10-2013 at 05:30 PM.

  4. #4
    Registered User
    Join Date
    02-01-2012
    Location
    Wales
    MS-Off Ver
    Excel 2007
    Posts
    45

    Re: Conditional Formatting a cell from a "true/false" VLOOKUP

    Just a little extra to go on..

    The ACTUAL call that I would like to conditional format contains:-
    =VLOOKUP(C5,'Sunday Duty Times'!$A$4:$N$99,2,FALSE)&"-"&VLOOKUP(C5,'Sunday Duty Times'!$A$4:$N$99,3,FALSE)
    of which gives me(in this case) 0752-1543, (Start time - Finish time)
    if the finish time is < 1600, conditional format this cell.

    Thanks in advance.

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Conditional Formatting a cell from a "true/false" VLOOKUP

    Try this...

    A2 = 0752-1543

    As the conditional formatting formula use:

    =--RIGHT(A2,4)<1600
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  6. #6
    Registered User
    Join Date
    02-01-2012
    Location
    Wales
    MS-Off Ver
    Excel 2007
    Posts
    45

    Re: Conditional Formatting a cell from a "true/false" VLOOKUP

    Dear Tony,
    Your solution works absolutely perfect!

    I would like to understand this a little better, please.
    first the --RIGHT ,what is this doing?
    I can see the A2 reads cell A2, but what is the ",4"

    many many thanks.

  7. #7
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Conditional Formatting a cell from a "true/false" VLOOKUP

    I'm assuming that all the times are entered as a string of 4 digits.

    A2 = 0752-1543

    RIGHT(A2,4)

    Returns N number of characters from right to left of the referenced cell. In this case N=4 so we want to return the 4 right-most characters from the value in A2:

    RIGHT(A2,4) = "1543"

    RIGHT(...) is a TEXT function so the value it returns is TEXT. In this case it returns the TEXT string "1543" which is not the same as the numeric value 1543.

    Since you want to do a logical comparison of this value to the numeric value 1600 we have to convert the TEXT string "1543" to the numeric value 1543.

    One way to do that is to use the double unary minus --.

    The inner - converts the TEXT number to a negative numeric number:

    -"1543" = -1543

    The outer - converts the negative numeric number to a positive numeric number:

    --1543 = 1543

    --RIGHT(A2,4) = 1543

    =1543<1600 = TRUE

  8. #8
    Registered User
    Join Date
    02-01-2012
    Location
    Wales
    MS-Off Ver
    Excel 2007
    Posts
    45

    Re: Conditional Formatting a cell from a "true/false" VLOOKUP

    Great stuff, Thanks!

  9. #9
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Conditional Formatting a cell from a "true/false" VLOOKUP

    You're welcome!

+ 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