Passing a checkbox object into a private sub doesn't work

Arcadian

Board Regular
Joined
Jul 27, 2004
Messages
111
Hi all,

I have a useform with a couple of checkboxes on it. Upon activating the userform I would like to run a couple of checks on the checkboxes. I want to use a private sub for that and pass the checkbox as an object into that sub, but no matter how I do it, I get an error 424 Object required. Below is my code:

VBA Code:
Private Sub UserForm_Activate()
    Dim chk As MSForms.CheckBox
    Set chk = UserForm4.CheckBox1
    
    Check_Active (chk)

End Sub

VBA Code:
Sub Check_Active(cb As MSForms.CheckBox)

    For Each v In Worksheets("Gebouw_eisen_nieuw").Range("D2:D" & Rows.Count)
        If v > "" Then
            If v = cb.Caption Then
                cb.Value = True
                cb.Tag = 1
                Exit For
            End If
        Else:
            cb.Value = False
            cb.Tag = 0
            Exit For
        End If
    Next

End Sub

It fails on the Check_Active (chk) line in the Userform Activate sub.
Any help is appreciated.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Remove the brackets:

VBA Code:
Check_Active chk
 
Upvote 0
Solution

Forum statistics

Threads
1,215,071
Messages
6,122,963
Members
449,094
Latest member
Anshu121

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top