+ Reply to Thread
Results 1 to 9 of 9

Conditional formatting with OR and INDIRECT functions not working

  1. #1
    Registered User
    Join Date
    10-13-2023
    Location
    Netherlands, Netherlands
    MS-Off Ver
    2016
    Posts
    6

    Post Conditional formatting with OR and INDIRECT functions not working

    Hello to all,

    I encountered this problem by chance and can't for the life of me figure out why it isn't working. A full explanation is given in the attached workbook, however, I will give some context.
    I want to apply conditional formatting on 4 cells if one of the 4 cells is a certain value, I want to do this for cell A1:A4, the to A5:A8 and so on.

    This is only a small part of the explanation of what I want and of what the problem is, the attached excel workbook explains everything in full.
    I sincerely hope someone can help me with this.

    Forum_Question-Conditional formatting with OR and INDIRECT.xlsx

    Kind Regards,

    Noah Disseldorp
    Last edited by Noah_Disseldorp; 10-16-2023 at 02:26 AM. Reason: SOLVED

  2. #2
    Registered User
    Join Date
    10-13-2023
    Location
    Netherlands, Netherlands
    MS-Off Ver
    2016
    Posts
    6

    Re: Conditional formatting with OR and INDIRECT functions not working

    Some extra information (For context see attachment):
    Instead of the formula below (which I used in the attached workbook) I have also tried a few other ways.
    =OR(INDIRECT(ADRESS(FLOOR((ROW(B2)-2)/4)*4+2;COLUMN(B2);1;1)&":"&ADRESS(FLOOR((ROW(B2)-2)/4)*4+5;COLUMN(B2);1;1))=$H$12)

    Tried alternatives:
    1. =OR(INDIRECT(ADRESS(FLOOR((ROW(B2)-2)/4)*4+2;COLUMN(B2);1;1))=$H$12;=OR(INDIRECT(ADRESS(FLOOR((ROW(B2)-2)/4)*4+3;COLUMN(B2);1;1))=$H$12;=OR(INDIRECT(ADRESS(FLOOR((ROW(B2)-2)/4)*4+4;COLUMN(B2);1;1))=$H$12)
    2. =IF(INDIRECT(ADRESS(FLOOR((ROW(B2)-2)/4)*4+2;COLUMN(B2);1;1))=$H$12;-1;1)*IF(INDIRECT(ADRESS(FLOOR((ROW(B2)-2)/4)*4+3;COLUMN(B2);1;1))=$H$12;-1;-1)*IF(INDIRECT(ADRESS(FLOOR((ROW(B2)-2)/4)*4+4;COLUMN(B2);1;1))=$H$12;-1;1)=-1

    Perhaps these formulas give you a better idea of what it is I'm trying to achieve.

    Sincerly,

    Noah Disseldorp

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Conditional formatting with OR and INDIRECT functions not working

    If I have understood you, you cannot take the formatting of one cell and apply it to another using a formula, so referencing H12 won't work. You need to set the formatting in the rule itself.

    It would help if you explained in WORDS what the objective is rather expecting us to reverse engineer formulae that are not actually doing what you want. Some detailed annotations in the workbook would help.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  4. #4
    Registered User
    Join Date
    10-13-2023
    Location
    Netherlands, Netherlands
    MS-Off Ver
    2016
    Posts
    6

    Re: Conditional formatting with OR and INDIRECT functions not working

    Thank you for your quick reply Ali,

    If I have understood you, you cannot take the formatting of one cell and apply it to another using a formula, so referencing H12 won't work. You need to set the formatting in the rule itself.
    - In that case why does the formula work when I remove the OR function. If I am not mistaken, it is this part of the formula -- ADRESS(FLOOR((ROW(B2)-2)/4)*4+2;COLUMN(B2);1;1) -- which determines which cell to check the value is equal to $H$12. The way I wrote it the adress function returns B2 for B2, B3, B4 and B5 and it returns B6 for B6, B7, B8 and B9. The idea being that it checks the same cell for a group of 4 cells and then moves on to the next group of 4 cells. Now If I want to return B3 for B2, B3, B4 and B5 I change ADRESS functions the row definition from -- FLOOR((ROW(B2)-2)/4)*4+2 -- to -- FLOOR((ROW(B2)-2)/4)*4+3
    So in short, each cell in the range I want the conditional formatting to apply is either TRUE or FALSE, and - when not using the OR function - it works perfectly, like I expect it to. But then, once I do use the OR function it no longer works, even though the exact same cells are being referenced as in the function without OR. Even more surprisingly the function with OR does work if I enter it in a cell below the range B2:F13 and spread it out over a range of the same size. The reference of $H$12 not being used not to take its formatting but to determine wether the function is TRUE of FALSE or in other words whether formatting for the cell should be applied.

    It would help if you explained in WORDS what the objective is rather expecting us to reverse engineer formulae that are not actually doing what you want. Some detailed annotations in the workbook would help.
    - On to the (in my opinion) more difficult question. As stated in the workbook, I have a table with some base data. I want to automatically retrieve the data in a planner-like view, this is being done by giving dates and times in columns next to the discipline, relation, location and description. Each row represents a task or a workflow and the information in the colums is either data to help with automatically placing the task in the planner-view or the data I want to place in the planner-view (the previously mentioned columns).
    Each task stretches over a multiple of cells like bars from top to bottom, I want to apply formatting to the 4 top cells of the "task card". Below an example of one of these task cards:

    2023-10-13_135157.png

    All the functionality of getting the proper data in the right place is working, and I am now down to applying the conditional formatting. I would like to use the formula's mentioned in my previous reply and used in the attached excel workbook to apply the formatting of my choice to tasks wich have either the discipline, relation or location in common.
    Usually I'd simply use Microsoft Project, but for reasons which would even take longer to explain I was hoping I could do it in excel. If all else fails I can always create more rules for the conditional formatting and basically force out the OR rule. However that is not really future-proof, if ever, I would want to be able to sort / colorcode on new columns containing new data I'd like to add to the "flashcards".


    Sorry for the extremely lengthy response, I understand that everyone is helping me in their free time, nevertheless, I believe it is a challenging and fun problem to solve and I wanted to share it. If it turns out it is simply not possible to do what I want to do, then so be it.
    Thank you all for your time.


    Sincerely,

    Noah Disseldorp

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Conditional formatting with OR and INDIRECT functions not working

    - In that case why does the formula work when I remove the OR function.
    I have probably misunderstood your purpose.

    It would be MUCH easier if you simplified this: instead of sharing partially working formulae with us, just povide a workbook with a BEFORE and AFTER mocked up, then we can see what it is taking you a lot of effort to try and explain.

  6. #6
    Registered User
    Join Date
    10-13-2023
    Location
    Netherlands, Netherlands
    MS-Off Ver
    2016
    Posts
    6

    Re: Conditional formatting with OR and INDIRECT functions not working

    Dear Ali,

    Thank you for your quick reply again. Indeed it takes me a lot of effort to explain, to be frank, I'm having a hard time doing so. However I'll give it another go using the picture below.
    2023-10-13_142528.png

    Don't worry creating the picture wasn't a lot of effort ;-)

    I still believe my previous response gives anyone the best chance of understanding what the problem is I've encountered. To put it simply:
    I have a working formula with the INDIRECT(ADRESS()) combination which works both in cells in the workbook and in the conditional formatting, this formula has three variations which all work seperately in the way I want them to work.
    However, when I combine the three formulas (which work) using an OR function, like this: OR(Variation1=Value; Variation2=Value; Variation3=Value). It still works in a cell in the workbook, but stops working in the conditional formatting rule.
    Variation1: =INDIRECT(ADRESS(FLOOR((ROW(B2)-2)/4)*4+2;COLUMN(B2);1;1))=$H$12 | works individually | returns TRUE
    Variation2: =INDIRECT(ADRESS(FLOOR((ROW(B2)-2)/4)*4+3;COLUMN(B2);1;1)) | works individually | returns FALSE
    Variation3: =INDIRECT(ADRESS(FLOOR((ROW(B2)-2)/4)*4+4;COLUMN(B2);1;1)) | works individually | returns FALSE
    Combination: =OR(Variation1=Value; Variation2=Value; Variation3=Value) | works only in a cell in the workbook | returns FALSE


    I don't think I can explain the problem any better the in the paragraph above. As for the purpose, I am hoping the attached picture will suffice.
    (I am not saying there isn't a better way to explain it or to make myself clear, but I don't think I can come up with one.)

    Again, thank you for your time!

    Sincerely,

    Noah Disseldorp

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Conditional formatting with OR and INDIRECT functions not working

    Can you please attach the workbook with the annotations? We can't work with a picture.

    I am trying my best to understand.

  8. #8
    Registered User
    Join Date
    10-13-2023
    Location
    Netherlands, Netherlands
    MS-Off Ver
    2016
    Posts
    6

    Re: Conditional formatting with OR and INDIRECT functions not working

    Hello to all,

    Over the weekend I've been able to solve the problem. As it turns out Excel indeed contains a bug when combining the INDIRECT function with IF, OR and AND functions in conditional formatting.
    At the end of this reply I've posted some links of similar problem encountered by others. In my case I wanted to apply conditional formatting if 1 of 3 functions was true, since all of the functions contained the INDIRECT function, the OR function didn't work.
    In the end I transformed =OR(Function1=Value,Function2=Value,Function3=Value) into =(Function1=Value)*1+(Function2=Value)*1+(Function3=Value)*1=>1, solving my problem.

    There is a page on StackOverflow by the name of conditional-formatting-using-row-inside-indirect-inside-and-doesnt-work. I'm not allowed to post links, so if you're interested a quick google search should suffice.

    Sincerely,

    Noah Disseldorp

    Link: https://stackoverflow.com/questions/...nd-doesnt-work
    Last edited by AliGW; 10-16-2023 at 02:27 AM. Reason: URL added.

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Conditional formatting with OR and INDIRECT functions not working

    Thanks for letting us know.

    If that takes care of your original question, please choose Thread Tools from the menu link above and mark this thread as SOLVED.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Using conditional formatting with INDIRECT
    By okela in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-11-2021, 10:53 AM
  2. Icon Set Conditional Format using Index+Indirect Not Working
    By Punnam in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 05-15-2019, 02:51 AM
  3. Conditional Formatting with Indirect
    By scott.garrett in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-14-2017, 01:09 PM
  4. [SOLVED] Sumproduct, sumif and indirect functions not working
    By stillyours786 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 12-28-2016, 06:01 AM
  5. [SOLVED] SUMPRODUCT and INDIRECT functions not working with a ROW reference when combined
    By Duoae in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-04-2014, 03:28 AM
  6. Replies: 0
    Last Post: 11-14-2013, 10:37 AM
  7. [SOLVED] functions and formatting not working
    By enedinamaddison in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-16-2013, 04:53 PM

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