+ Reply to Thread
Results 1 to 6 of 6

Conditional formatting error

  1. #1
    Registered User
    Join Date
    10-06-2019
    Location
    Zagreb, Croatia
    MS-Off Ver
    MS Office 2007, MS Office 365
    Posts
    4

    Question Conditional formatting error

    Hello there,

    just made an account freshly, for I have a question. I have a problem with conditional formatting.

    I have a table used to keep track of presence in class, and it has a row with dates which has date-format values. What I want is to highlight a column which corresponds with the current date. I used this formula in conditional formatting, which worked:

    =TODAY() = INDIRECT(ADDRESS(5;COLUMN())) - the dates are always in 5th row, and the date is written at the top of the column(in row 5), hence I used the INDIRECT function to determine which cell to check the TODAY() date against. That is all clear to me.

    Now the problem is when I try to expand on this formula. I want to have 2 different highlight colors depending on a cell($D$3), who's value will contain a certain string. Let's say I want the highlight to be blue when the cell contains string "Fast", and orange when it contains string "Last". For other reasons, I want to check if those strings are contained anywhere within the cell, so instead of using a pure '$D$3="Fast"' comparison, I decided on using:

    =ISNUMBER(SEARCH("Fast";$D$3)) - the SEARCH outputs the index number where the string starts if it is found in the specified($D$3 in this case) cell, and then I get the 'TRUE/FALSE' using ISNUMBER - if SEARCH outputs number, it obviously found the string inside the cell, and if it doesn't, it returns '#VALUE!', which I'm guessing is a sort of NULL value(it actually doesn't matter for my case). Long story short, this formula outputs TRUE if a cell contains the wanted string, and FALSE if it is not contained inside the string. Again, this formula works.

    I then go ahead, and combine these two formulas to get this:

    =AND((TODAY() = INDIRECT(ADDRESS(5;COLUMN()))); ISNUMBER(SEARCH("Fast";$D$3))) - what this formula does is outputs TRUE only if the cell $D$3 contains string "Fast" and the column header(again, in row 5) contains the current date. This formula, when inserted into the sheet on any cell WORKS - so it works as intended. The problem appears when I use this formula in the conditional formatting - it simply doesn't work.

    Again, I'm trying to highlight cell in a column whose header's date is today's date, and I want the colour to be different based on a separate cell.
    I tried using just the date checking formula, and it worked. I tried using just the string-in-cell checking formula, and it worked, but when I combine the 2 into a single formula, which has been tested and it outputs TRUE and FALSE as expected, it suddenly doesn't work.
    Last edited by Fichom; 10-06-2019 at 02:42 PM.

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,728

    Re: Conditional formatting error

    I'm not sure why you are using the INDIRECT(ADDRESS … construct - why not just refer to the cell reference directly?

    It would help if you attached a sample Excel workbook.

    To do this, click on Go Advanced (below the Edit Window) while you are composing a reply, then scroll down to and click on Manage Attachments and the Upload window will open. Click on Browse and navigate to (and double-click) the file icon that you want to attach, then click on Upload and then on Close this Window to return to the Edit window. When you have finished composing your post, click on Submit Post.

    Don't try to use the Paperclip icon, as it doesn't work on this forum.

    Hope this helps.

    Pete

  3. #3
    Registered User
    Join Date
    10-06-2019
    Location
    Zagreb, Croatia
    MS-Off Ver
    MS Office 2007, MS Office 365
    Posts
    4

    Re: Conditional formatting error

    The reason I used this was because the formula has to work in conditional formatting, for a wide range of cells. You can't use 'direct reference' because for every column, you are referencing a different cell, and I of course don't want to create a new rule and formula for every column, especially since I have well over 40 of them, and well, if I have to expand the amount of columns to, god forbid, 100+ columns... well, you see the problem.

    I'll add the sheet here - I cleaned it out because it contains personal information, so only dates are left. I also added two rows with the formula used in conditional formatting, so you can see that they indeed output TRUE, and despite this, conditional formatting is not working.
    Attached Files Attached Files

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,728

    Re: Conditional formatting error

    I see that your CF rule for TODAY() (i.e. the one that generates an orange background fill) applies to the range =$G$6:$BC$59, so all you need to do is to select Manage Rules on the CF dialogue box with G6 selected, then Edit Rule and change the condition to:

    =TODAY() = G$5

    When you click OK Excel will automatically adjust the cell reference to suit all the cells in that range.

    Similarly for the other condition (blue fill), which also applies to the range =$G$6:$BC$59 - click on Edit Rule and change the formula to this:

    =AND(TODAY() =G$5, ISNUMBER(SEARCH("Fast",$D$3)))

    When you click OK again the reference will change, and as G$5 is used then the G will change for other columns but the $5 will remain the same on different rows. The cell reference $D$3 will not change.

    Hope this helps.

    Pete

  5. #5
    Registered User
    Join Date
    10-06-2019
    Location
    Zagreb, Croatia
    MS-Off Ver
    MS Office 2007, MS Office 365
    Posts
    4

    Re: Conditional formatting error

    Mhm, I see your method works, but more importantly:

    1. Why doesn't my formula work, even though it is correct? I'm honestly more concerned with that question rather than with it actually working or not.
    2. Also, I see it all over the place in tutorials and forums, but why do people always use ',' symbol instead of ';' symbol to end statements for formulas? I mean, in all the versions of Excel I ever worked with, ',' gives an error, and you always have to insert ';'.

    Thank you for your help!

  6. #6
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,728

    Re: Conditional formatting error

    I don't know why your construct does not work, as I've never tried doing it that way. It might be that you have to specify the sheet name in the ADDRESS function, as conditional formatting is fussy about that.

    The regional settings in Excel determine whether you need to use a comma ( , ) or a semicolon ( ; ) to separate parameters in formulae. In the USA (where Excel originated), and in much of the English-speaking world a full-stop is used to indicate a decimal point in a number, and a comma is used to separate parameters. In much of continental Europe, however, a comma is used as a decimal point, and so a different symbol has to be used to separate parameters in formulae - that is where the semicolon comes in. If you have only ever used Croatian versions of Excel, then you will only have come across semicolons as a list separator.

    Hope this helps.

    Pete

+ 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. Conditional Formatting Error
    By Dnyan in forum Excel General
    Replies: 2
    Last Post: 08-23-2017, 12:10 PM
  2. [SOLVED] Conditional Formatting error
    By rojashan in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-04-2014, 12:31 AM
  3. Conditional Formatting - Run Time Error '13' Type Mismatch Error
    By ksp in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-17-2011, 07:37 PM
  4. [SOLVED] Conditional formatting error, odd!
    By bob in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-01-2006, 01:45 PM
  5. [SOLVED] conditional formatting for Error
    By krupesh in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 PM
  6. conditional formatting for Error
    By krupesh in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 11:05 AM
  7. conditional formatting for Error
    By krupesh in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 11:05 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