Command Button on Userform that checks Checkboxes are Ticked

slimimi

Well-known Member
Joined
May 27, 2008
Messages
532
Hi there - i am using excel 2003.
I have created a userform with Checkboxes and command buttons.

Is it possible to do the following:

On command button "OK" Click - check to see that all checkboxes have been ticked before proceeding.

If all checkboxes have not been ticked - display message "Please tick your Checkboxes before proceeding".

There are 3 checkboxes in question.

Look forward to anyones response on this.
THank you.
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Hi,

try...

Code:
Private Sub CommandButton1_Click()
    Dim frmControl As MSForms.Control
    Dim intNumber As Integer
    For Each frmControl In UserForm1.Controls
        If TypeOf frmControl Is MSForms.CheckBox Then
            If frmControl = False Then
                intNumber = intNumber + 1
            End If
        End If
    Next
    If intNumber > 0 Then MsgBox "Please tick your Checkboxes before proceeding"
End Sub
Case_Germany
 
Upvote 0

Forum statistics

Threads
1,214,967
Messages
6,122,503
Members
449,090
Latest member
RandomExceller01

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