3

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?

Community
  • 1
  • 1
Max Segal
  • 1,955
  • 1
  • 24
  • 53

1 Answers1

1

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.

joehua
  • 725
  • 3
  • 10
  • 25