Consulting

Results 1 to 9 of 9

Thread: Changing cells' format

  1. #1

    Changing cells' format

    Hello
    Simetimes I have such a problem. For example I have numeric value "5" in a cell. But I want it to be treated like string. I change format to text, but its not a text yet. It becomes a text string only after editing this cell.
    Is this normal or some bug in Excel?
    Im using Office2003 on WinXP

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Change it to '5, a leading apostrophe.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    It's not the way. If entering apostroph then I'll better stand on each cell and put F2 and Enter. But I have already few tables with numbers that should be treated like strings. It's not a problem to do this with 100-200 cells.

    I'm interested how to avoid this problem in future. If this behavior is needed for some reason - then let it be. But if it's not normal then I'd like to know how to fix it.
    Thanks

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    okay, so explain what you mean by '... treated like a string ...'. you can do that with a number, so what is the problem?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    Formatted like string
    =IF(A1=A2;1;0)

    this formula shows 0 if cells have different format. (A1 - string; A2 - number). After changing A2 formatting to text it still doesn't work. Select A2, press F2 and Enter. After this formula shows 1

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Try this

    =IF(--A1=--A2;1;0)
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    Works. Thanks
    Can you explain why?

  8. #8
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Basically, it is coercing a text value to its numeric equivalent. So, if you have text 5, it coerces it to numeric 5. Then you you are just comparing numbers to numbers.

    Note it will error on strings.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  9. #9
    So I cant compare cells as strings. It's a pitty. Cause I can have "0050" and "50" and this are different.
    But thanks anyway

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •