Require checkbox to be checked before processing

G

Guest

Hi

I have a simple userform with 3 checkboxes, and I require that at least one checkbox has been checked. If this condition isn't met, then I'll show a message box to instruct this

My question is: How can I suspend the macro from processing the next line until this condition is met? (ie. After the user clicks OK on the msgbox, I'd like the userform to remain there so they can check the checkbox(es), and then click the "Run" button on the userform to resume the macro

My current code is as below

----------------------------------------------------
Private Sub cmdRun_Click(

If chk1 or chk2 or chk3 Then
Unload Me
DoEvent
<other code here...

Els

MsgBox "Please check at least one box", vbOKOnly + vbApplicationModal + vbCritical, "Selection Required

End I

End Su
 
T

Tom Ogilvy

Your macro already does that. It doesn't suspend execution, but once you
are in the else branch, after the msgbox is closed, the macro ends. The
userform remains and when the user clicks the cmdRun button, the macro
starts over - if a box is checked, it closes the form.

--
Regards,
Tom Ogilvy


SuperJas said:
Hi,

I have a simple userform with 3 checkboxes, and I require that at least
one checkbox has been checked. If this condition isn't met, then I'll show a
message box to instruct this.
My question is: How can I suspend the macro from processing the next line
until this condition is met? (ie. After the user clicks OK on the msgbox,
I'd like the userform to remain there so they can check the checkbox(es),
and then click the "Run" button on the userform to resume the macro.
My current code is as below:

-----------------------------------------------------
Private Sub cmdRun_Click()

If chk1 or chk2 or chk3 Then
Unload Me
DoEvents
<other code here...>

Else

MsgBox "Please check at least one box", vbOKOnly +
vbApplicationModal + vbCritical, "Selection Required"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top