+ Reply to Thread
Results 1 to 4 of 4

Conditional formatting : Zeroes and blanks

  1. #1
    Forum Contributor
    Join Date
    01-26-2005
    Posts
    108

    Conditional formatting : Zeroes and blanks

    After years of using Excel I have discovered today that Excel considers a numeric zero to be the same as an empty cell (at least in conditional formats).

    The background to this, in case it helps, is that I have a series of expected results from a test run (in column E) and these are compared to a set of actual results loaded in from a SQL Server database (in column H).

    My conditional format compares two cells using a formula like this ...
    Please Login or Register  to view this content.
    H50 and E50 are the cells being compared.
    $B$2 is a flag to determine whether or not SHOW the difference (using a pattern of red)
    The "*" test is there to allow certain values to be ignored as they are known to always be different, timestamps for example.

    What I am seeing is a numeric zero in E50 being compared to a NULL (empty cell) in H50 and being considered (by Excel) as identical.

    I COULD alter the underlying data to make all cells text but this would be difficult to achieve across the project (hundreds of workbooks).

    Can anyone help with a method of getting this compare to work "properly"?

    Thanks in advance.
    Tony

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Try instead:

    Please Login or Register  to view this content.
    Note: You don't actually need to create an IF() statement in conditional formatting....it's an IF by default...just need to include the IF_TRUE part....
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,712
    If you use EXACT function this will distinguish between a zero and a blank cell, i.e.

    =AND(NOT(EXACT(H50,E50)),$B$2="Y",E50<>"*")

    Note: EXACT is case-sensitive so, unlike your previous formula, "Hat" in E50 will be deemed different to "HAT" in H50

  4. #4
    Forum Contributor
    Join Date
    01-26-2005
    Posts
    108
    Thankyou both for your responses.

    NBVC - yours was fine (thanks) except it didn't allow for both cells being empty, it did, however, lead me to something that DID work 100%. many thanks.
    My solution (in case anybody else wants it later) was ...
    Please Login or Register  to view this content.
    DaddyLongLegs, then I read yours which is a much neater and more complete solution than mine, many thanks.

    Thanks both also for the lesson on conditional formatting not needing the IF, I've used it for years and years without knowing that.

+ 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