+ Reply to Thread
Results 1 to 5 of 5

Why the same ASCII code shows different symbols in Excel?

  1. #1
    Registered User
    Join Date
    08-31-2012
    Location
    Rio, Brazil
    MS-Off Ver
    Excel 2003
    Posts
    11

    Question Why the same ASCII code shows different symbols in Excel?

    It's crazy.
    I paste the symbol in Excel in A1 and I put the formula =code(A1) in B2.
    It shows 63.
    After I digit =char(63) in A2, it shows ? symbol.
    When I test =(A1=A2) it's false
    If I copy formula and paste value for A2, it continue to be false.
    Why? How is it possible the same ASCII code shows two different symbols?
    My version is Excel 2003 and Excel 2010.

  2. #2
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Why the same ASCII code shows different symbols in Excel?

    I have noticed the same thing when trying to identify troublesome characters in workbooks uploaded here. CODE() identifies the character as one thing and CHAR() gives a different character for that code. It must have something to do with character sets.
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Why the same ASCII code shows different symbols in Excel?

    CODE gives the numeric code for ASCII characters. However, ∞ is not an ASCII character. If you do Symbol, Insert, you will see in the Symbol window that this symbol is represented by Unicode code x221E. It is not in the ASCII character set. The decimal code is actually 8734. I am not sure of the arithmetic that causes CODE to return 63 (I thought it might be modulo 256 but that's not the case), but it gives a false result for characters with codes above 255.
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Registered User
    Join Date
    08-31-2012
    Location
    Rio, Brazil
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Why the same ASCII code shows different symbols in Excel?

    I've make some addition research.

    When you copy and paste a symbol like ∞, the Excel writes ∞ (unicode)

    ∞ is a unicode 8734 (EE12), as the previous user told us
    and there's no special reason why code(∞) is 63, like "?" symbol, but it's a
    fake value.

    If you write
    Please Login or Register  to view this content.
    in a cell using VBA, the cell shows ∞
    if you write
    Please Login or Register  to view this content.
    in a cell with ∞, the function return 8734

    So you can use AscW in order to find if the character is unicode or not.
    If it returns a number less than 256 it is not, otherwise it is.

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Why the same ASCII code shows different symbols in Excel?

    To emphasize something that Paulo Buchsbaum wrote, AscW and ChrW are not worksheet functions, they are VBA functions. If you want to use this functionality in a worksheet you can write UDFs:

    Please Login or Register  to view this content.
    I gave the UDFs names that are different than the VBA names to avoid name collision. You can use any name you want.

+ 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. Formula in ASCII code
    By grey_hair in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-13-2013, 11:37 AM
  2. [SOLVED] VBA code to go from character to ASCII
    By uduyt in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-27-2012, 12:11 PM
  3. Replies: 0
    Last Post: 06-14-2007, 02:19 AM
  4. ASCII Code Question
    By DCSwearingen in forum Excel General
    Replies: 2
    Last Post: 10-30-2006, 02:51 PM
  5. [SOLVED] Ascii symbols
    By Percy in forum Excel General
    Replies: 5
    Last Post: 07-21-2006, 10:00 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