supermercadinho
New Member
- Joined
- Aug 24, 2022
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
Hello,
If anyone can help me understand the inner workings of this code, I'd greatly appreciate the help.
And this piece that works together
This is all in reference to another thread (Dynamic CheckBox control in a VBA UserForm) about dynamically generating check boxes from an array. My own code is very similar to this one but I have it loop through an array of names that I gave it and it works. I want to know how to then find and reference those clicked check boxes so that I can use some sort of logic to filter out data in another series of codes I have running in my macros such as this.
If anyone can at least help me understand more about the first code posted I'd greatly appreciate it.
If anyone can help me understand the inner workings of this code, I'd greatly appreciate the help.
VBA Code:
' in code module for clsRunTimeCheckBox
Public WithEvents Checkbox As MSForms.Checkbox
Event Change()
Private Sub Checkbox_Click()
Set UFParent.ActiveCheckBox = Me
RaiseEvent Change
End Sub
Property Get UFParent() As Object
Set UFParent = Checkbox.Parent
On Error Resume Next
Do
Set UFParent = UFParent.Parent
Loop Until Err
On Error GoTo 0
End Property
And this piece that works together
Code:
' in userform code module
Dim AddedCheckBoxes As Collection
Public WithEvents ActiveCheckBox As clsRunTimeCheckBox
Private Sub ActiveCheckBox_Change()
MsgBox ActiveCheckBox.Checkbox.Name
End Sub
Private Sub UserForm_Initialize()
Dim i As Long
Dim newBox As clsRunTimeCheckBox
Set AddedCheckBoxes = New Collection
For i = 1 To 6
Set newBox = New clsRunTimeCheckBox
With newBox
Set .Checkbox = Me.Controls.Add("forms.CheckBox.1")
With .Checkbox
.Caption = "MyBox" & i
.Width = 150
.AutoSize = True
.Top = 5 + 20 * (i - 1)
End With
End With
AddedCheckBoxes.Add Item:=newBox
Next i
End Sub
This is all in reference to another thread (Dynamic CheckBox control in a VBA UserForm) about dynamically generating check boxes from an array. My own code is very similar to this one but I have it loop through an array of names that I gave it and it works. I want to know how to then find and reference those clicked check boxes so that I can use some sort of logic to filter out data in another series of codes I have running in my macros such as this.
Code:
If frmGroupProjectsBy.ckbProjPhaseArchive.Value = False And strProjectPhase = "Archive" Then
GoTo SkipToNextRow
Else
'Do Nothing
End If
If anyone can at least help me understand more about the first code posted I'd greatly appreciate it.