Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force English MonthName in VBA

Tags:

excel

vba

My system configurations are set to Hebrew.

I want this function to return an English string:

MonthName(month(ActiveSheet.Range("i9").Value)))

but it returns Hebrew month name.

I tried to apply what works for me in excel formatting menu but it doesn't seem to work in Vba. What I tried is to add another argument:

MonthName(month(ActiveSheet.Range("i9").Value)),"b1mmmm")

with no luck...

I will appreciate any help.

like image 767
Max Segal Avatar asked Jan 10 '23 16:01

Max Segal


1 Answers

I'd avoid fighting the locale settings if I were you as whatever you do probably will not end up being portable.

One way, and quite nice insofar that it's a spreadsheet-based solution, is to use

=CHOOSE(,"January","February", "March", "April", ..., "December")

Where the first argument points to a number between 1 and 12.

In VBA you could always set up an array and index that.

like image 132
Bathsheba Avatar answered Jan 19 '23 13:01

Bathsheba