Reputation: 187
I currently have a code that creates text boxes dynamically on a userform back story is here.
In the code it checks a single frame on the form for controls and if any are ticked then it runs this code:
Function Addcheckboxes(emailtype)
Dim Ctrl As Control
Dim cont As Control
Dim i As Long
Dim h As Long
Dim intAppCount As Integer
Dim result As Long
' Loop through all the applications that have been selected with the email type and then create the appropriate email template on the userform lower box
If SpnColct.Count > 0 Then removeDynamicControls
For Each Ctrl In Me.Frame4.Controls
If TypeOf Ctrl Is MSForms.CheckBox Then
If Ctrl = True Then
Call AddTextBox(Mid(Ctrl.Name, 4), emailtype)
intAppCount = intAppCount + 1
End If
End If
Next
If intAppCount > 1 Then Me.Frame3.Caption = "Email Templates"
End Function
How do I expand this to make it check both Frame 4 and Frame 5 on the userform ?
Thank you in advance
Upvotes: 0
Views: 196
Reputation: 8104
You can loop through each frame as follows...
Dim Frm As Variant
For Each Frm In Array(Me.Frame4, Me.Frame5)
For Each Ctrl In Frm.Controls
If TypeOf Ctrl Is MSForms.CheckBox Then
If Ctrl = True Then
Call AddTextbox(Mid(Ctrl.Name, 4), emailtype)
intAppCount = intAppCount + 1
End If
End If
Next
Next Frm
Upvotes: 1