This is my first post on this forum. So far I've managed to solve every difficulty by browsing the available answers. This time I can't.
I used this example to create a self populating userform (Userform1) with some checkboxes with events defined in the way described on the example, by Creating a class module with the code to run and assigning the class sub to the checkbox.
The UserForm1 was then replicated to several case scenarios and all works fine when these userforms are called explicitly by their names (ex: UserForm1.show) but now I call the several userforms in a "for" cicle that runs through another set of checkboxes in my worksheet to decide which userforms to initialize. Each userform is stored in an object variable (UForm) through a function based on its name, and then it is initialized, and now the events of the userforms' checkboxes do not trigger!!
Sub Test()
Dim chk As Object
Dim Uform As Object
Dim strForm as String
Dim MMarray(0 To 3, 1) As String '3 so far, more to be added
MMarray(0, 0) = "Chk1": MMarray(0, 1) = "UserForm1"
MMarray(1, 0) = "Chk2": MMarray(1, 1) = "UserForm2"
MMarray(2, 0) = "Chk3": MMarray(2, 1) = "UserForm3"
MMarray(3, 0) = "Chk4": MMarray(3, 1) = "UserForm4"
' #############################
' initializing global variables defined elsewhere
iMM = 0 '
ReDim data_ini(0, 0)
ReDim data_MM_tot(0, 1)
For i = 0 To UBound(MMarray)
Set chk = ActiveSheet.Shapes(MMarray(i, 0))
If chk.OLEFormat.Object.value = 1 Then
strForm = MMarray(i, 1)
Set Uform = GetFormObjectbyName(strForm)
Uform.Show
Call Uform.repor 'this is another sub in the userform code
End If
Next i
End Sub
I assume the issue has to do with the fact that there is an ongoing procedure when the form is shown and that's why the events can't be triggered. Is there a way to get the events to be triggered in these circumstances?
Thanks a lot for your help.