Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't use GBP (£) symbol in VBA

Tags:

excel

vba

I have English version of Excel and Polish regional settings. I try to make a code which will give cells formatting with pound symbol before number value.

Unfortunately it is converted to "L" when I paste the symbol to VBA window. Macro recorder also records cells formatted this way as "L". Chr(163) returns "Ł".

Changing system language setting, localization settings or keyboard settings had no effect. Only after changing regional settings (requires PC restart) to English (Great Britain) it works correctly. Is there any way I could use this symbol without changing regional settings?

like image 962
Ryszard Jędraszyk Avatar asked Dec 19 '16 12:12

Ryszard Jędraszyk


1 Answers

If you want to apply the symbol to the formatting via VBA, try:

Sub Serling()
    Const g = "General"
    dq = Chr(34)
    sterl = " " & ChrW(163)
    s = g & dq & sterl & dq
    Selection.NumberFormat = s
    Selection.Font.Name = "Arial Unicode MS"
End Sub

enter image description here

EDIT#1:

To me, this is really cool. If you want degrees Celsius, use ChrW(8451): if you want degrees Fahrenheit, use ChrW(8457), etc.

like image 157
Gary's Student Avatar answered Oct 25 '22 22:10

Gary's Student