Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel VBA Checkboxes English vs French

I have an Excel file which needs to deal with checkboxes. The names of the checkboxes are defined automatically in French (due to my installation being french). For example "Case à cocher 100" instead of "Checkbox 100".

However, when our sibling company uses this Excel file, it crashes due to their installation being English.

Is there a way to make the following work for English and French?

ActiveSheet.CheckBoxes("Case à cocher 488").Interior.Color = RGB(255, 255, 255)
ActiveSheet.CheckBoxes("Case à cocher 383").Interior.Color = RGB(255, 255, 255)
ActiveSheet.CheckBoxes("Case à cocher 467").Interior.Color = RGB(255, 255, 255)
ActiveSheet.CheckBoxes("Case à cocher 461").Interior.Color = RGB(255, 255, 255)
ActiveSheet.CheckBoxes("Case à cocher 460").Interior.Color = RGB(255, 255, 255)
ActiveSheet.CheckBoxes("Case à cocher 459").Interior.Color = RGB(255, 255, 255)
ActiveSheet.CheckBoxes("Case à cocher 458").Interior.Color = RGB(255, 255, 255)
ActiveSheet.CheckBoxes("Case à cocher 8").Interior.Color = RGB(255, 255, 255)

I can't seem to find a way to rename the checkbox's name.

like image 551
Alex Avatar asked Feb 05 '23 08:02

Alex


1 Answers

Check for the regional settings and then decide which one to use.

Try this

Sub Sample()
    Dim CBNAME As String

    Select Case Application.International(XlApplicationInternational.xlCountryCode)
        Case 1 '<~~ English
            CBNAME = "CheckBox"
        Case 33 '<~~ French
            CBNAME = "Case à cocher"
    End Select

    ActiveSheet.CheckBoxes(CBNAME & " 488").Interior.Color = RGB(255, 255, 255)
End Sub
like image 196
Siddharth Rout Avatar answered Feb 13 '23 00:02

Siddharth Rout