Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable Unicode in Excel 2016 VBA editor [duplicate]

I have a worksheet with Hebrew word "שלום" in cell A1.

I am trying to run this VBA code:

Sub test()
    Dim str As String
    str = Range("A1")
    MsgBox str
End Sub

The message box displays:

????

Also, when I try to write Hebrew characters in VBA code:

if range("A1") = "שלום" then 'do something...'

instead of Hebrew letters I see gibberish.

I use Excel 2016 on Windows 10. Hebrew language pack is installed.

I did not face this problem in Excel 2010 on Windows 7.

Anyone with an idea for enabling Hebrew (or Unicode in general) in VBA code?

like image 393
Max Segal Avatar asked Jan 26 '26 00:01

Max Segal


1 Answers

You need to set system locale to Hebrew.

Different version of Windows has a slightly different way of doing it. Search the net for how to do it on your version of Windows. Basically, it is in Control Panel/Language & Region. If you are using Windows 10, it is under Settings/Time & Language/Region/Additional Date, Time, & Regional Setting (on the upper right hand corner of the window)/Region (change date, time, or number formats)/Administrative.

like image 196
joehua Avatar answered Jan 28 '26 19:01

joehua



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!