0

On a PC I have these chars with their ASCii code 178,188,189 respectively. But when I use the CODE function on MAC VBA Excel I always get 95 for all three different chars.

char    PC  MAC
²       178 95
½       188 95
¾       189 95

How can I distinguish between these 3 chars on the MAC? or phrased differently, is there a function on the MAC VBA Excel that gives me different values for these 3 chars, even if they are "MAC Ascii" values, as long as they are different

Unihedron
  • 10,902
  • 13
  • 62
  • 72
user387184
  • 10,953
  • 12
  • 77
  • 147
  • How do these characters "arrive" on the Mac? Do they come from a PC generated workbook? Do they show up correctly in the cells? – Floris May 18 '13 at 23:29
  • I get them in a txt file and copy that into excel on the mac or on the pc – user387184 May 18 '13 at 23:31
  • Could be a file encoding issue, ansi vs utf8 etc – NickSlash May 18 '13 at 23:34
  • How is the txt file encoded? – Floris May 18 '13 at 23:34
  • How do I find that out? – user387184 May 18 '13 at 23:35
  • What application created it? – Floris May 18 '13 at 23:39
  • Whats the "code" function? – NickSlash May 18 '13 at 23:39
  • Take a look at [this link](http://www.vbaexpress.com/forum/showthread.php?t=25095) – Floris May 18 '13 at 23:40
  • the "code" function in Excel VBA gives you the Ascii code of a char, but for these 3 chars on the MAC I get 95, while on a PC I get 3 different values - I don't know the name of the program that created the text - it just comes as a txt file and works on the PC but not on the MAC – user387184 May 18 '13 at 23:42
  • When I save it in Notepad on MAC it defaults to UTF-8, so I gues it's UTF-8. How do I now get three different UTF-8 encoding values for these 3 different chars? – user387184 May 18 '13 at 23:44
  • The problem (i think) is that the vba editor on mac doesnt understand utf-8 (multi-byte characters). The worksheet functions should handle it find though, so you will probably need to pass your data to the workbook, and process it then pull it back into vba. – NickSlash May 18 '13 at 23:46
  • I have the text in Excel cells and want to work with them from within some VBA code within Excel, so the text is not in the code but as values in the Excel cells – user387184 May 18 '13 at 23:50

1 Answers1

0

The table you gave for the ASCII codes is wrong.

The correct table is:

char    PC  MAC
²       178 253
½       189 171
¾       190 243

Hope it helps

Newbie
  • 863
  • 1
  • 7
  • 16
  • Hello, yes for PC you are right, I just mixed up one line - to get these numbers I used the CODE function on PC. BUT ON MAC I ALWAYS GET 95 WHEN I USE THE CODE FUNCTION. HOW DID YOU GET THESE NUMBERS ON THE MAC? ps the three chars are in three cells in an Excel spreadsheet and the CODE function is either in a formula or in VBA code, makes no difference – user387184 May 19 '13 at 06:53
  • i got the numbers [here](http://www.theasciicode.com.ar/extended-ascii-code/superscript-two-exponent-2-square-second-power-ascii-code-253.html) – Newbie May 19 '13 at 11:53
  • OK, thanks. Unfortunately the function on the MAC does not work correctly and does not return the correct value. Thank's for your help! – user387184 May 19 '13 at 12:10
  • 1
    How do you get these values from a function? On other words, what code will tell you what character is in the cell if it was imported from a PC (or what is the ASCII code of the value in the cell)? That seems to be the real question... I don't understand why this is marked as "answered"! – Floris May 21 '13 at 02:52