Readdy Write  
0,00 €
Your View Money
Views: Count
Self 20% 0
Your Content 60% 0

Users by Links 0
u1*(Content+Views) 10% 0
Follow-Follower 0
s2*(Income) 5% 0

Count
Followers 0
Login Register as User

Excel Checkbox in vba mit 0 oder 1 setzen checked

12.03.2019 (👁879)

Excel vba Checkbox Wert Checked setzen

Wie kann man auf eine Checkbox in einer Excel Anwendung per vba Makro Code das Checked oder unchecked setzen.

Lösung

Per Checkbox.OLEFormat.Object.Valeu

ctlCheckbox.OLEFormat.Object.Value = True

 

 

 

Code Beispiel

    '----< @Loop: optional_Control_Inputs >----

    '*Excel Checkboxen

    Dim ctl As Shape

    For Each ctl In ws.Shapes

        If ctl.Type = msoFormControl Then

            '---< Ist_Namesvariable_mit_Kennung >---

            Dim ctlCheckbox As Shape

            Set ctlCheckbox = ctl

 

            Dim sCheckbox_Text As String

            sCheckbox_Text = ctl.AlternativeText

            '< correktur >

            '*loesche Klammer-Texte wie Vorjahr(VJ)

            Dim posCheck As Integer

            posCheck = InStr(1, sCheckbox_Text, "(", vbBinaryCompare)

            If InStr(1, sCheckbox_Text, "(", vbBinaryCompare) > 0 Then

                sCheckbox_Text = Mid$(sCheckbox_Text, 1, posCheck - 1)

                sCheckbox_Text = Trim(sCheckbox_Text)

            End If

            '</ correktur >

 

            '-< init >-

            Dim optChecked As Boolean

            optChecked = list_Daten.ListColumns(sCheckbox_Text).DataBodyRange(row.Index)

 

           

            If optChecked = True Then    'Excel Checkbox.child=checked

                ctlCheckbox.OLEFormat.Object.Value = True

            Else

                ctlCheckbox.OLEFormat.Object.Value = False

            End If

            '-</ init >-

 

           

            Application.StatusBar = Now & " " & sCheckbox_Text & "=" & optChecked

 

            '---</ Ist_Namesvariable_mit_Kennung >---

        End If

    Next

    '----</ @Loop: optional_Control_Inputs >----