excelvbaregional-settings

How to detect COMA or DOT as decimal for multilanguage excel-vba macros


I made a excel with vba that should work regardless the local setting for comas and dots, now, I have manually this detection and load one or another macro depending the user.

how can I detect this setting on vba ?


Solution

  • After readiing post How to get the user's language in Excel with VBA? I think you could use:

    Application.International(xlDecimalSeparator) will return the character used as Decimal Separator.

    Application.International(xlThousandsSeparator) will return the character used as thousands separator.

    My test:

    Sub test()
    
    'Spanish Excel with spanish setup
    'My decimal separator is comma
    'Thousands separators is dot
    
    Debug.Print "Decimal: " & Application.International(xlDecimalSeparator)
    Debug.Print "Thousands: " & Application.International(xlThousandsSeparator)
    End Sub
    

    Output I get:

    enter image description here