ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   CheckBox in userform (https://www.excelbanter.com/excel-programming/318209-checkbox-userform.html)

MD

CheckBox in userform
 
I'm building a UserForm that has CheckBoxes (called say CB1). The code that
I want to inclued is when CB1 is chcked do this else do that. My start off
bub looks klike this.... but it doesn't work!!!!

Private Sub Bouton_print_Click()

If CB1.Value = True Then
'.... do this
Else
'.... do that
End If
End Sub


Reagrds,

MD




Ron de Bruin

CheckBox in userform
 
Hi MD

This is working for me with a button with the name "CommandButton1"
and a checkbox with the name "Cb1"

Private Sub CommandButton1_Click()
If Me.Cb1.Value = True Then
MsgBox ".... do this"
Else
MsgBox ".... do that"
End If
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"MD" wrote in message ...
I'm building a UserForm that has CheckBoxes (called say CB1). The code that I want to inclued is when CB1 is chcked do this else
do that. My start off bub looks klike this.... but it doesn't work!!!!

Private Sub Bouton_print_Click()

If CB1.Value = True Then
'.... do this
Else
'.... do that
End If
End Sub


Reagrds,

MD






Bob Phillips[_6_]

CheckBox in userform
 
Are you sure the button is called Bouton_print?

This is a simpler version of your code that works

Private Sub Bouton_print_Click()
MsgBox IIf(CB1, "Do this", "Do that")
End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)


"MD" wrote in message
...
I'm building a UserForm that has CheckBoxes (called say CB1). The code

that
I want to inclued is when CB1 is chcked do this else do that. My start

off
bub looks klike this.... but it doesn't work!!!!

Private Sub Bouton_print_Click()

If CB1.Value = True Then
'.... do this
Else
'.... do that
End If
End Sub


Reagrds,

MD







All times are GMT +1. The time now is 12:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com