Excel VBA xlcountrycode always returns 1 = US

M

MikeVBA

I have been using a VBA script for 3-4 years now with no issues, but just
recently noticed a problem with new PC's or refreshed to new laptops where
the region seems stuck to US (1).

Despite changing the PC region/local language in Control panel to "English
UK" - it always reads 1. Is there a hiden registry entry where a PC OS build
can force xlcountrycode to 1 (US) , even though date format/locale shows and
works as UK(44).

I can take the same file VBA acript onto my PC or another PC run it and
returns "44" for the UK as expected. Yet if I compare the Region-Language
settings thoroughly to format/customise etc etc - they are identical.

So why do our new PC's think they are US - xlcountrycode returns "1" always

sample code below
===============
If Application.International(xlCountrySetting) <> 1 And
Application.International(xlCountrySetting) <> 2 Then
deal_info(7) = Format(Cells(row_ptr_b, date_ref), "dd-mmm-yyyy")
Else
deal_info(7) = Format(Cells(row_ptr_b, date_ref), "mmm-dd-yyyy")
End If
 
J

JLGWhiz

The help file says that xlCountryCode is the version of Excel, and
xlCountrySetting is the Windows international setting.
 
M

MikeVBA

Apologies I was so entralled with the problem , i used the wrong
term.......... "xlcountry setting" is always returning 1 when it should
return 44.....as you can see in the VBA code I am checking <xlcountrysetting>.

I aslo wrote this region check routing as a test spreadsheet - both come up
1 - despite being English UK region/locale, keyboard Uk etc etc.....but it
never returns 44 for the new User PC's, when it should for UK.


Sub test()
Dim excel_view As Long
Dim windows_view As Long

excel_view = Application.International(xlCountryCode)
windows_view = Application.International(xlCountrySetting)
Cells(2, 5) = "Excel Country code - where I am"
Cells(2, 4) = excel_view
Cells(4, 5) = "Microsoft Windows OS view - where I am"
Cells(4, 4) = windows_view
End Sub
 
Z

ZackB

Late post I know, but in the future, if someone is looking for an answer. Try using xlcountrysetting instead, this should work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top