lundi 30 décembre 2019

How do I call upon checkboxes with groupname or tag?

Am creating a form in which the user will be able to select 4 checkboxes. Blue, Green, Yellow, Red. They have to do this atleast twice, up to 5 times in total.

The first checkboxes are on the form, the other 4 grouped checkboxes are on multipages.

I've tried giving them a group name "Reeks" to "Reeks4", to then print their values into a single cell separated by comma.

The code I've found so far does print the values neatly, however, it grabs every available checkbox on my form instead of just from the group "Reeks".

The ways I've tried to add the groupname (or tag, named them both the same) to the code, only gives me errors.

For Each Control In Me.Controls
   If TypeName(Control) = "CheckBox" Then
               'If Control.GroupName = "Reeks" Then
                If Control.Value Then 
            Reeks = IIf(Reeks <> "", Reeks & ", ", "") & Control.Caption
        End If
        End If
    Next
With ws 
.Cells(iRow, 5).Value = Reeks
End With

Any help is welcome, but if at all possible please add comments as I only started on VBA last week.

(Side note. I also have framed checkboxes on the multipages in which the user can select the location of said colour. Side + Top view. Which will need to work the same as with the colours, but printed in different columns. )




Aucun commentaire:

Enregistrer un commentaire