Search code examples
excelvbaregional-settings

What setting is causing Excel VBA to change the named Range.Style "Percent" to "Per cent"?


I have an xlsm workbook that gives a "Subscript out of range" error in response to ThisWorkbook.Styles("Percent").Value on one system but not on another. On the system that throws the error the style named "Percent" seems to have been replaced by one called "Per cent". I suspect this has its origins in language settings differing on the two computers. The working system is set to English (UK) throughout but I'm unable to establish which setting or combination of settings would result in Excel renaming the style internally without warning. Changing some of the settings to English (United States) seems to be non-trivial and I'm scared to mess up my computer trying to do so. Can anyone enlighten me as to what is going on here?


Solution

  • After further investigation, I now have an answer - an unexpected one.

    My main machine has all Windows settings set to English (United Kingdom). On my start menu, under Microsoft Office Tools, there’s an Office Language Preferences application where the preferred Office display language is set to Match Microsoft Windows [English]. Excel shows a style named "Percent" with these settings.

    On a test system with the same initial settings I added the Office display language called English (United Kingdom). With the preferred Office display language set to Match Microsoft Windows [English (United Kingdom)] Excel shows a style named "Per cent" and no style named "Percent". I had to add an Office display language called English (United States) and make it the preference in order to see a style named "Percent" again.

    You couldn't make it up. "Match Microsoft Windows [English]" is VERY misleading on a system where Windows is set to English (United Kingdom) across the board.