unicode characters in VBA editor

dannnv

New Member
Joined
Sep 3, 2005
Messages
7
I am using old version of Excel, 97. This may be solved in later version but would like to know if it can be solved in Excel 97. I am making an xls to xml convertor. The first thing I need to do is replace characters with the unicode equivalent so that they can be properly displayed in xml. I am using this code repeatedly in my VBA macro for each character I expect to be a problem

Cells.Replace What:="¢", Replacement:="¢", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False

The issue is that I cannot paste certain characters into the What:=" ", because the editor does not recognize them. An example is the square root sign. If I try and paste it from character map is is not a radical sign in the editor.

Any way around this??

Thanks Dan
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Supported Operating Systems: Windows 95; Windows 98; Windows 98 Second Edition; Windows ME

Are you sure? I am running XP. The MS site does not say it supports XP. I have newer operating system , its the Excel version that is old.
 
Upvote 0
Hi Dan

You can also use the character Unicode value.

For ex., the code of the square root character is hexadeximal 221A.

Write something with the letter "V" in A1 (ex: "V169") and try:

Code:
Range("A1").Replace What:="V", Replacement:=ChrW(&H221A), LookAt:=xlPart, MatchCase:=False
 
Upvote 0
THanks pgc01,

Although I needed to use your advice in reverse. I need to put the hexidecimal code to search for the character I cannot paste into the editor. When I pasted a square root symbol into an excel cell, it actually found it and replaced it with the unicode string.

Cells.Replace What:=ChrW(&H221A), Replacement:="√", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False

I just to to get the hex codes for the characters I am looking for.

Thanks again

D
 
Upvote 0
I'm sorry but I don't understand.

I hope one of these options helps.

If you mean that you'd like to find a character and you don't know its code you'll have to search
- in xl 2007 you can do it in Insert->Symbol
- in previous versions you can use the OS Character Map (in the Accessories) or use the Paste symbol in word and copy to excel
- an alternative is to google for it

If you mean you have imported or pasted a text with symbols into a cell and you'd like to know its Unicode code, use the AscW() function.
For ex., to know the Unicode code of the second character in A1 in decimal

MsgBox AscW(Mid(Range("A1"), 2, 1))

or in hex

MsgBox Application.WorksheetFunction.Dec2Hex(AscW(Mid(Range("A1"), 2, 1)))

Hope this helps
 
Upvote 0

Forum statistics

Threads
1,215,143
Messages
6,123,277
Members
449,093
Latest member
Vincent Khandagale

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top