mardi 5 avril 2022

List all Captions of checked checkboxes in a single cell [closed]

I'm trying to use a formular with checkboxes. It's supposed to display the captions of the checkboxes, that are toggled, in one cell(G26 in the activeSheet). I don't have any experience with VBA and I'm searching for a solution on stackoverflow. I already found one code, but it seems to be not finished.

I already tried the following code, but the GetSelection is not properly defined. And i do not really know what that's supposed to mean. I Thought the GetSelection IS the definition of my procedure. I'd appreciate any help!

Private Sub GetSelection()

    Dim c As MSForms.Control
    Dim cbk As MSForms.CheckBox
    Dim sel As String
    
    For Each c In Me.Controls
        If TypeOf c Is MSForms.CheckBox Then
            Set cbk = c
            If cbk = True Then
                If sel = "" Then
                    sel = cbk.Caption
                Else
                    sel = sel & "," & cbk.Caption
                End If
            End If
        End If
    Next
    sheetActiveSheet.Range ("G") & .Row("26").Value2 = sel
End Sub

Private Sub CheckBox4_Click()
    GetSelection
End Sub



Aucun commentaire:

Enregistrer un commentaire