+ Reply to Thread
Results 1 to 7 of 7

Conditionally format numbers stored as text

  1. #1
    Registered User
    Join Date
    04-14-2010
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    24

    Conditionally format numbers stored as text

    Hi all,
    I think this question really gets at a larger issue but here goes:

    I'm doing a conditional format of a cell and I'm just comparing it to the cell next to it, and highlighting the cell if it's different than the one next to it. IE, in A1 the condition is <> A2.

    It doesn't work...the issue seems to be this ongoing thing about what's a number and what's not. Cell A1 and A2 are both formatted as Text but *currently* contain only digits, ie, A1 = 1033 and A2 = 1033 but the A1 still gets highlighted.

    I tested by changing the condition to <> INT(A2) and it works. Since these cells may contain alpha, I can't use INT() reliabley and I don't want to get into the hassle of using IF(), etc. within the format logic--I guess if I have to then I have to, but I get to a point and think "There's got to be an easier way".

    Soooo...how do I get Excel to simply compare the cells as I have explicitly formatted them without writing a hundred lines of code in a formula that simply compares one cell to another? It's as if Excel is looking at numeric data as numeric--but only on one side of the comparison, it's not consistent in it's annoying tendencies.

    What is the best way to get around this?
    Thanks,
    --Jim
    Last edited by NBVC; 05-06-2011 at 03:50 PM.

  2. #2
    Forum Expert ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    Victoria, Canada
    MS-Off Ver
    2010
    Posts
    2,952

    Re: Conditionally format numbers stored as text

    Hi Jim,

    How about this:

    Please Login or Register  to view this content.
    Cheers,
    Would you like to say thanks? Please click the: " Add Reputation" button, on the grey bar below the post.

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Conditionally format numbers stored as text

    Can you clarify:

    Quote Originally Posted by jimojimo
    highlighting the cell if it's different than the one next to it. IE, in A1 the condition is <> A2.
    ie - next to it would imply A1<>B1 test rather than A1<>A2

    Quote Originally Posted by jimojimo
    Cell A1 and A2 are both formatted as Text but *currently* contain only digits, ie, A1 = 1033 and A2 = 1033 but the A1 still gets highlighted.
    This would not be, unless, one of the cells was formatted as Text after the values were first input.
    Changing a cells format post data entry does not alter the value in any way - ie typing 10 into A1 and then formatting A1 as text does not make 10 into a text string (ie <> "10"... ISNUMBER remains True).
    If you were to re-enter 10 then at that point the value would become a text string "10".

    By the sounds of it A1 was entered pre formatting and A2 was not - ie A1 is a number and A2 is a text string.

    Quote Originally Posted by jimojimo
    how do I get Excel to simply compare the cells as I have explicitly formatted them without writing a hundred lines of code in a formula that simply compares one cell to another?
    Well, the above rather depends on whether you correct the original entries per the first point...
    ie per your condition above and your original post A1 and A2 are different based on their format yet you seemingly want to contradict the logic rule and treat as identical.
    I'm afraid you can't have it both ways so to speak - either they are different based on their format or they aren't (based on their coerced content) - and if the format is important you must re-enter your values as appropriate.
    Last edited by DonkeyOte; 04-28-2010 at 04:05 AM. Reason: Meant pre rather than post

  4. #4
    Registered User
    Join Date
    04-14-2010
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Conditionally format numbers stored as text

    Donkey,
    My bad about the cell example...it should have been A1 and B1 as the examples, but the point is the same.

    << This would not be, unless, one of the cells was formatted as Text after the values were first input. >>

    I will have to check and see what's happening with the order of when they're input, etc. There is code that copies a recordset to the column and formats it, but the formatting is always the same and never cleared before the recordset is moved in.

    Conne,
    When I try using A1<>Text(B1) instead of A1<>Int(B1) it does not work because now A1 is not text. And within the conditional formatting I can't force the left side of the equation to be wrapped in Text(). I tried putting that in the Applies To range, but excel simply stripped the function. That's some true frustration.

    Thanks for any more help on this,
    --Jim

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Conditionally format numbers stored as text

    Quote Originally Posted by jimojimo View Post
    When I try using A1<>Text(B1) instead of A1<>Int(B1) it does not work because now A1 is not text. And within the conditional formatting I can't force the left side of the equation to be wrapped in Text().
    Try using the "use a formula to determine which cells to format" option within CF then use the formula

    =A1&""<>B1&""

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Conditionally format numbers stored as text

    dll, I think the fundamental point remains though

    Quote Originally Posted by jimojimo
    how do I get Excel to simply compare the cells as I have explicitly formatted them
    ie if formatting is meant to be seen as means for differentiation normalising does not make a great deal of sense.

    I suspect the reality is such that actually the format isn't that important (ie "10" and 10 should be treated as the same) and if so:

    =NOT(EXACT(A1,B1))

    might also suffice if case sensitivity is important (ie apple <> Apple, but "10" = 10)

  7. #7
    Registered User
    Join Date
    04-14-2010
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Conditionally format numbers stored as text

    DaddyLongLegs,
    That was perfect! That did the job and I'm good to go, Thanks,
    --Jim

+ 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