how do i create a macro to clear checkboxes and display a message.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Im doing an excel sheet for work and need to program a macro so that say when
two checkboxes are checked at the same time it unchecks them and creates a
message box signifying an error. Maybe even have it play a sound too
 
Why not just use Option Buttons instead of Check Boxes. They only allow one
to be checked at a time?

HTH
 
Well the problem is I want the checkboxes to either have one checked or none
because im doing a business model for capital equipment so that it can only
have one add-on and not the other or none of them. Having three option
buttons would look odd on the sheet.
 
I have about Ten "sets" of checkboxes that have the same problem
In order for this to work i simply used the click event of the checkboxes
(if they are form controls) to check the other check box eg you have two
check boxes, one is named WHITE the other is named BLACk

this is in the sheet module

private sub WHITE_click ()
if WHITE.value = true and BLACK.value = TRUE then
WHITE.value = false
BLACK.value = false
Beep
msgbox "You can not do that.
end if
end sub
 
you can play wave files, i'm not sure of the exact syntax but saerch vba help
for "wave" or playsound
ben
 
I named the check boxes as you said and im getting an end sub error when I
try clicking one of the boxes. Was i not supposed to assign the macro to one
of the check boxes? Where do i assign the macro to?
 
Ben I'm getting an end sub error so when I tried taking out the private part
it highlights the If WHITE.Value = True And BLACK.Value = True Then and gives
me an error for some reason its not working
 

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

Back
Top