ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel VBA xlcountrycode always returns 1 = US (https://www.excelbanter.com/excel-programming/418417-excel-vba-xlcountrycode-always-returns-1-%3D-us.html)

MikeVBA

Excel VBA xlcountrycode always returns 1 = US
 
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



JLGWhiz

Excel VBA xlcountrycode always returns 1 = US
 
The help file says that xlCountryCode is the version of Excel, and
xlCountrySetting is the Windows international setting.

"MikeVBA" wrote:

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



MikeVBA

Excel VBA xlcountrysetting always returns 1 = US
 
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

"JLGWhiz" wrote:

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

"MikeVBA" wrote:

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



ZackB

Excel VBA xlcountrycode always returns 1 = US
 
Late post I know, but in the future, if someone is looking for an answer. Try using xlcountrysetting instead, this should work.

On Sunday, October 12, 2008 6:00 PM MikeVB wrote:


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



On Sunday, October 12, 2008 7:15 PM JLGWhi wrote:


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

"MikeVBA" wrote:



On Monday, October 13, 2008 3:59 AM MikeVB wrote:


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

"JLGWhiz" wrote:



Submitted via EggHeadCafe
ASP.NET Base64 Image Encoding via the Data: protocol
http://www.eggheadcafe.com/tutorials...-protocol.aspx



All times are GMT +1. The time now is 04:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com