View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Determine check status of worksheet checkbox?

You could assign it a macro (rightclick on it an assign macro).

Option Explicit
Sub testme()

Dim myCBX As CheckBox
Set myCBX = ActiveSheet.CheckBoxes(Application.Caller)

If myCBX.Value = xlOn Then
MsgBox "It's checked"
Else
MsgBox "It's not checked"
End If

End Sub

This goes in a general module.

By using this line:
Set myCBX = ActiveSheet.CheckBoxes(Application.Caller)
You can assign the same macro to all the checkboxes -- and still know which one
was clicked (Application.caller will return its name).

robotman wrote:

Thanks! xlOn works....but who at Microsoft developed that?!! Now I
don't feel so bad for not figuring that out. And xlOff = -4146?

My macro will be cross-platform and objects from the VB Toolbox don't
function correctly on a Mac (at least not drop down boxes). I'm not
sure why, but I'm forced to use the Forms toolbox on the worksheet.

** Is there any way to capture events with the Forms checkbox (like
when the checkbox is checked/unchecked)? **

Thanks!

John


--

Dave Peterson