+ Reply to Thread
Results 1 to 24 of 24

Function in Conditional Formatting Not Working

  1. #1
    Registered User
    Join Date
    05-29-2013
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    6

    Exclamation Function in Conditional Formatting Not Working

    So I have a function that I placed into excel's "Conditional Formatting", which should turn a cell "Red" if the function returns True, else leave the cell alone if the function returns false. (Using the Rule type: Use a formula to determine which cells to format)

    My formula is:

    =IF(ISNUMBER(MATCH(INDIRECT("S"&ROW()+4),INDIRECT(ConvertToLetter(MATCH(INDIRECT("R"&ROW()+4),DropDown!1:1,0))),0)), TRUE, FALSE)

    The whole equation behaves the way I expected it to, returning true if there is a match and false if there isn't, but isn't turning the cell red despite being "true".

    To give a step by step on what happens near the end of the evaluation of the function, after all calculations are done:
    =IF(ISNUMBER(2), TRUE, FALSE)
    =IF(TRUE, TRUE, FALSE)
    =TRUE

    I was wondering what I'm doing wrong, which results in the conditional formatting not working.
    Logically, it should work but I am not that experienced in excel so maybe there is something I am overlooking.

  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
    53,048

    Re: Function in Conditional Formatting Not Working

    try this (untested, as I dont have your data)...
    =ISNUMBER(MATCH(INDIRECT("S"&ROW()+4),INDIRECT(ConvertToLetter(MATCH(INDIRECT("R"&ROW()+4),DropDown!1:1,0))),0))

    That will return either a TRUE or FALSE value by itself, and thats what CF needs. With complex formulas like that for CF, I often create them IN the worksheet, and play with them until i get the required T or F answer 0 its much easier to edit in the W/S than in the CF window
    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
    Registered User
    Join Date
    05-29-2013
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Function in Conditional Formatting Not Working

    Thank you for your reply!

    I have tried your code and the CF still isn't working properly despite me getting the correct T and F

    The function I have should be correct. I tested it in different scenarios and I obtained the expected results.

    In terms of testing, I'm observing the output of the function in the worksheet. So when it results in true in the worksheet, it should also be resulting in true in the CF since they have the same formula.
    Last edited by quack618; 05-31-2013 at 06:09 PM.

  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
    53,048

    Re: Function in Conditional Formatting Not Working

    If you enter that formula, copied down, to where you want the CF applied, does it giove the required T/F?
    Have you got the range correct?
    Is the CF being applied starting at the correct row?
    The formula seems pretty complex, why the need for the indirects?

  5. #5
    Registered User
    Join Date
    05-29-2013
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Function in Conditional Formatting Not Working

    1. Yes, I entered the formula both in the cell and in the CF for that cell.
    2. Range? I'm using the "Use a formula to determine which cells to format" Rule type so I don't have a range.
    3. So the way I'm going about this is I'm referencing the row 4 lines below my testing cell (hence the +4 in the formula).
    I am messing with the variables in that row and can confirm that the variables are affecting the formula in the cell 4 rows above.
    4. So the indirects are referencing to the elements in the cell.
    For example: INDIRECT("S"&ROW()+4) --> INDIRECT("S"&9) --> INDIRECT(S9) --> Jellybeans.

    The INDIRECT, outside of the other nested INDIRECT function, somewhat confuses me yet is required for my formula to work. I obtain INDIRECT("Array!AD:AD") which then results in Array!AD:AD (without the quotation marks).

    I apologize if these answers do not directly answer your questions. I'm not that experienced in excel so everything is very new to me.

    I would attach the documentation for you to use but it contains some important information so I will try to duplicate it with different elements and upload that.

  6. #6
    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
    53,048

    Re: Function in Conditional Formatting Not Working

    2. Range? I'm using the "Use a formula to determine which cells to format" Rule type so I don't have a range.
    There has to be a range, but guessing isnt going to solve this 1, I will wait until you can provide a sample file

  7. #7
    Registered User
    Join Date
    05-29-2013
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Function in Conditional Formatting Not Working

    I apologize for taking so long with the sample file!
    I had successfully replicated the problem using the same environment of the original file.

    So for the new file, I want to check if the item in the cell 'B2' is in the category for cell 'A2'.
    So if the item is 'Apple' and category is 'Fruit', then it should return True.
    If the item is 'Apple' and the category is 'Vegetable', then it should return False.

    I'm using cell 'D2' as a form of feedback to ensure that I am getting the correct True/False.
    The Conditional Formatting takes place in cell 'B2'; it is using the same formula that cell 'D2' is using.
    In other words, if cell 'D2' is true, then the CF in cell 'B2' should be true, which would result it in filling the cell with the color light-blue.

    Thank you for your help so far!
    Last edited by quack618; 06-01-2013 at 10:46 PM.

  8. #8
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,960

    Re: Function in Conditional Formatting Not Working

    You must upload your files directly to the forum. Don't make members take side excursions. Besides, it's easier.
    To Attach a Workbook:
    1. Click on Go Advanced
    2. In the frame Attach Files you will see the button Manage Attachments
    3. Click the button.
    4. A new window will open titled Manage Attachments - Excel Forum.
    5. Click the Browse... button to locate your file for uploading.
    6. This will open a new window File Upload.
    7. Once you have located the file to upload click the Open button. This window will close.
    8. You are now back in the Manage Attachments - Excel Forum window.
    9. Click the Upload button and wait until the file has uploaded.
    10. Close the window and then click Submit
    Ben Van Johnson

  9. #9
    Registered User
    Join Date
    05-29-2013
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Function in Conditional Formatting Not Working

    I apologize.

    I don't see an "Attach" button when I edit my old post so I will make a new post and remove the link from my old post.
    Attached Files Attached Files

  10. #10
    Valued Forum Contributor
    Join Date
    05-20-2013
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2013
    Posts
    941

    Re: Function in Conditional Formatting Not Working

    Haven't figured out the why, but apparently your formula results in TRUE in the W/S but not in CF. I replaced the CF formula with =D2 and it correctly highlighted B2.

    BTW, exactly what are you trying to accomplish with the formula... the contents A2 and B2 match, on DropDown sheet, the header Fruit in B2 and one of the members below it? It appears you've already accomplished that with data validation. However, I'm aware that data validation falls short once the value is selected, because either A or B entry can be deleted and there will be no error message. I suggest applying CF to highlight (red?) A or B entries if they are blank.
    Last edited by jhren; 06-02-2013 at 12:46 AM.

  11. #11
    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
    53,048

    Re: Function in Conditional Formatting Not Working

    Try this simpler approach (although, not knowing what your real data looks like, you will have to test)
    I added a helper column on sheet2 after B (Fruit) and used this, copied down, to give me a fruit/type combo
    =B$1&B2
    I gave this a named range Fruit1
    Then I did same for Vegetable (Vegetable1)

    Then I used this for my CF...
    Highlight B2:B5
    click CF - new rule - use formula
    =ISERROR(VLOOKUP(A2&B2,INDIRECT(A2&1),1,0)) format fill RED

    I am using 2007, it does not have ConvertToLetter, nor can it reference another sheet directly

  12. #12
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Function in Conditional Formatting Not Working

    Okay, if you Highlight B2-B#, and apply this formula :
    =MATCH(B2,Vegetable,0)
    then select format, fill, red
    it will highlight all the vegetables in red, change the 'Vegetable' to 'Fruit' and you get that highlighted;

    Not exactly sure what you expect from the sample...there is no explanation of why the cell(s) should be hi-lighted or not so ...
    A picture may be worth a thousand words, BUT, a sample Workbook is worth a thousand screenshots!
    -Add a File - click advanced (next to quick post), scroll to manage attachments, click, select add files, click select files, select file, click upload, when file shows up at bottom left, click done (bottom right), click submit
    -To mark thread Solved- go top of thread,click Thread Tools,click Mark as Solved
    If you received helpful response, please remember to hit the * of that post

  13. #13
    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
    53,048

    Re: Function in Conditional Formatting Not Working

    @ Dred, I think they want to highlite the 2nd D/D if the 1st was changed and the 2nd doesnt match up now?

  14. #14
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Function in Conditional Formatting Not Working

    AHH, okay, think I'm seeing the picture now...

  15. #15
    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
    53,048

    Re: Function in Conditional Formatting Not Working

    well, thats what makes sense to me, anyway - I have been know to be wrong before lol

  16. #16
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Function in Conditional Formatting Not Working

    Maybe this then :
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Drag down

    I moved "Lettuce" int the 'Fruit' list and changed the range definition for fruit to include it (probable unnecessary, but better safe than sorry)
    This highlights any value in column B that does not exist in the named range from column a

    Hope this helps
    Attached Files Attached Files

  17. #17
    Valued Forum Contributor
    Join Date
    05-20-2013
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2013
    Posts
    941

    Re: Function in Conditional Formatting Not Working

    If so, =ISNA(MATCH(B2,INDIRECT(A2&""),0))

  18. #18
    Valued Forum Contributor
    Join Date
    05-20-2013
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2013
    Posts
    941

    Re: Function in Conditional Formatting Not Working

    @dred

    In moving Lettuce to Vegetable, you didn't change the named range to include it, so it is outside both named ranges being checked. Besides, INDIRECT(A2) always returns an error (#VALUE!) because A2 "is" direct... that's why my formula uses INDIRECT(A2&"").

  19. #19
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Function in Conditional Formatting Not Working

    Well...I did miss the expansion to include lettuce, thanks for the heads up...however, MY machine does NOT return an error for the Indirect(a2), it returns the 'named range' range values, (check column E to see the worksheet results of the formula), so not sure what is happening on your machine..
    Last edited by dredwolf; 06-02-2013 at 01:54 AM.

  20. #20
    Valued Forum Contributor
    Join Date
    05-20-2013
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2013
    Posts
    941

    Re: Function in Conditional Formatting Not Working

    Yep... I rechecked and its not doing what it did before. I could say it was glitch in my machine, but it was most likely operator error

  21. #21
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Function in Conditional Formatting Not Working

    LOL , it happens

  22. #22
    Registered User
    Join Date
    05-29-2013
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Function in Conditional Formatting Not Working

    Thank you everybody for your responses!

    I used dredwolf's solution "=ISERROR(MATCH(B2,INDIRECT(A2),0))" and it worked!!
    Thank you so much dredwolf!!

    My gosh, your code is like 1/4 the size of the code I had...

    So for clarification on the purpose of this: What I am trying to accomplish is sort of like an error check. When you change "categories", the element under "item" doesn't change respectively with it.
    An example would be: I choose my category as “Fruit” and item as “Apple”. If I decide to change the category to “Vegetables”, the element “Apple” still stays. By highlighting the cell, I would easily be able to pinpoint the rows where the items do not fall under the correct category and can correct them right away.

    Though my problem has been solved, I do have one more question for better understanding: in the code "=ISERROR(MATCH(B2,INDIRECT(A2),0))" that is being applied to $B$2:$B$5, are the values 'B2' and 'A2' dynamic? Meaning do they internally change to B3 A3, B4 A4, or B5 A5 if being applied to that specific row? I hope this question makes sense.

  23. #23
    Valued Forum Contributor
    Join Date
    05-20-2013
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2013
    Posts
    941

    Re: Function in Conditional Formatting Not Working

    Quote Originally Posted by quack618 View Post
    ...Though my problem has been solved, I do have one more question for better understanding: in the code "=ISERROR(MATCH(B2,INDIRECT(A2),0))" that is being applied to $B$2:$B$5, are the values 'B2' and 'A2' dynamic? Meaning do they internally change to B3 A3, B4 A4, or B5 A5 if being applied to that specific row? ...
    Yes......

  24. #24
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Function in Conditional Formatting Not Working

    @ jhren, TY for the answer "yes"
    @quack618
    You are quite 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