+ Reply to Thread
Results 1 to 20 of 20

Conditional Formula with Text

  1. #1
    Registered User
    Join Date
    01-17-2013
    Location
    MA, US
    MS-Off Ver
    Excel 2010
    Posts
    4

    Conditional Formula with Text

    For each row, evaluate Column E and then check Column G for contents

    If E is Greater than 85 AND G contains "Express" I want to highlight the Cell in E.

    My formula:
    =IF(AND(INDIRECT("E"&ROW())>=85,(FIND("Express",INDIRECT("G"&ROW())),"TRUE","False"))

    When I try this formula in Conditional format I get wonderfully descriptive window dialog: "The formula you typed contains an error"

    Tried this in a regular cell and stepped through it, says there is an error and suggests THIS formula:
    =IF(AND(INDIRECT("E"&ROW())>=85,(FIND("Express",INDIRECT("G"&ROW())))),"TRUE","False")

    However, this returns #Value if there any value in G that does NOT contain Express
    but functions correctly otherwise.

    I am sure that it is just a need to set the false to a value but it returns a 1 for Express and nothing for anything else.

    I tried adding "true","False" throughout the formula but have been not successful in getting a valid formula.

    Any help?

  2. #2
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Conditional Formula with Text

    Why are you using INDIRECT in the formula? It seems you're just checking cells on the same row, which you can do with conditional formatting without needing to use INDIRECT.

    If, say, the range you're formatting is A2:A100 then you'd use the formula:

    =AND(E2>=85,ISNUMBER(FIND("Express",G2)))

    Conditional formatting will automatically adjust the row numbers being checked for every cell in your range.

    BTW, you get the #VALUE error because if the string "Express" isn't found then FIND doesn't return a FALSE, it returns a #VALUE error, but you can trap this using ISNUMBER.

  3. #3
    Valued Forum Contributor
    Join Date
    05-08-2012
    Location
    Georgia, USA
    MS-Off Ver
    Excel 2003, 2010
    Posts
    811

    Re: Conditional Formula with Text

    In cell E1 enter this formula as a conditional format criteria
    =AND(E1>85,F1="Express")

    Copy the format down
    Click on star (*) below if this helps

  4. #4
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,453

    Re: Conditional Formula with Text

    Perhaps add the ISNUMBER function like =IF(AND(INDIRECT("E"&ROW())>=85,(isnumber(FIND("Express",INDIRECT("G"&ROW()))),"TRUE","False"))

    Why do you need the INDIRECT function?

  5. #5
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    wales
    MS-Off Ver
    Excel 2007
    Posts
    964

    Re: Conditional Formula with Text

    without seeeing you book its tricky but try this

    Please Login or Register  to view this content.
    The Importance of INDEX - A GUIDE TO INDEX'S OTHER USES
    <--- If a post helps hit the star

  6. #6
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Conditional Formula with Text

    Oh, and if you conditional formatting is being applied to multiple columns then you'd probably want to use the formula:

    =AND($E2>=85,ISNUMBER(FIND("Express",$G2)))

    But still write it as if it applies only to the first row of the range you're conditionally formatting.

  7. #7
    Valued Forum Contributor
    Join Date
    05-08-2012
    Location
    Georgia, USA
    MS-Off Ver
    Excel 2003, 2010
    Posts
    811

    Re: Conditional Formula with Text

    Andrew-R:
    The formula should be greater than 85 not greater than or equal to 85

  8. #8
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Conditional Formula with Text

    K m:

    The OP says "greater than" in the text of their post, but is using >= in their formula.

    Your formula isn't what they require because they specify that column G (not column F) contains "Express", not is equal to "Express"

  9. #9
    Valued Forum Contributor
    Join Date
    05-08-2012
    Location
    Georgia, USA
    MS-Off Ver
    Excel 2003, 2010
    Posts
    811

    Re: Conditional Formula with Text

    Andrew-R:
    Touché: You are right about my formula. I elected not to correct it since others already had the correct approach

  10. #10
    Registered User
    Join Date
    01-17-2013
    Location
    MA, US
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Conditional Formula with Text

    You are correct about my >= 85, that was a mistake it should just be >84.

    As for why I am using Indirect - to reduce the # of formulas and keep this in the Conditional Formatting.
    I am not doing this in the row, but from the Conditional Formating area and did not want to add a formula for each row.

    I tried the suggested =IF(AND(INDIRECT("E"&ROW())>=85,(isnumber(FIND("Express",INDIRECT("G"&ROW()))),"TRUE","False"))
    but that did not work in the conditional OR in a cell check.

  11. #11
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    wales
    MS-Off Ver
    Excel 2007
    Posts
    964

    Re: Conditional Formula with Text

    did you try my solution. (i would really avoid the indirect though) i have done conditional formatting for rows before and you don't need it.

    take a look at the book.

    example.xlsx

    not that I have used the >84 as you requested and also note that Express <> express according to our formula. if you don't care about capitalisation then you need to alter FIND to SEARCH)

  12. #12
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Conditional Formula with Text

    You don't need to do the formula for each row - we understand that it's conditional formatting you're using.

    Select the whole range you want to format, choose to use a formula and enter the formula:

    =AND($E2>84,ISNUMBER(FIND("Express",$G2)))

    (Assuming that row 2 is the first row you are conditionally formatting). Conditional formatting will sort the rest out, there's no need to do it for every row.

  13. #13
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Conditional Formula with Text

    Quote Originally Posted by twiggywales View Post
    if you don't care about capitalisation then you need to alter FIND to SEARCH)
    Both will cause problems, because they both return #VALUE if the text isn't found.

  14. #14
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    wales
    MS-Off Ver
    Excel 2007
    Posts
    964

    Re: Conditional Formula with Text

    check the book i don't think it matters. if its not there it wont highlight
    or am I missing something

  15. #15
    Registered User
    Join Date
    01-17-2013
    Location
    MA, US
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Conditional Formula with Text

    E G Value I want returned.

    10 Express FALSE
    90 Express TRUE
    200 Standard FALSE
    20 Standard FALSE

    I tried the =AND($E2>84,ISNUMBER(FIND("Express",$G2))) formula - it did not work as expected.

    However the suggested by Twiggywals DOES:
    =AND($E1>84,FIND("Express",$G1,1))

    Thank you for the quick response and teaching me that you DONT need indirect in conditional (my misunderstanding) and that excel is smart enough to correctly apply this out to the row!

    Thank you, thank you, thank you!

  16. #16
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Conditional Formula with Text

    The only reason my formula doesn't work as expected is that your data obviously starts on row 1, and not row 2, but I've told you in three times in this thread that it has to be written as if it applies to the first row you're formatting.

  17. #17
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    wales
    MS-Off Ver
    Excel 2007
    Posts
    964

    Re: Conditional Formula with Text

    Quote Originally Posted by Andrew-R View Post
    The only reason my formula doesn't work as expected is that your data obviously starts on row 1, and not row 2, but I've told you in three times in this thread that it has to be written as if it applies to the first row you're formatting.
    I knew what you meant but excel conditional formatting can be a bit daunting until you get to grips with it.

    I know that when i first started looking at conditional formatting I didn't have a clue and it wasn't until someone gave me a working book explaining how it worked that it clicked.

  18. #18
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Conditional Formula with Text

    It's why people should always post example workbooks - it makes it much more likely they'll get a working solution

  19. #19
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    wales
    MS-Off Ver
    Excel 2007
    Posts
    964

    Re: Conditional Formula with Text

    cant disagree with that. (that is one thing that really bugs me when I have to try and construct what I think the have to check it works)

  20. #20
    Registered User
    Join Date
    01-17-2013
    Location
    MA, US
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Conditional Formula with Text

    Actually, it starts on Row 5 and the columns were not as posted, I used those values to simplify my issue.
    I actually updated both formulas according to the sheet I was currently working on (1 workbook, multiple sheets, different columns and starting rows on each sheet) two with detail, lastly a summary sheet.

    I was trying not to muddy the water with extraneous information that was not pertinent to the issue and would likely have sidetracked people down roads that were not the issue.

    I am new to the forum, I am not totally new to excel. I did not know you could upload excel workbooks on this forum so I was trying to give detail to the issue. With all the virus and issue that can cross with them I was trying to keep it simple.

    That being said, when I have an issue here again, I will upload a sample.

    Thanks

+ 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