Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a checkbox on a worksheet but can't figure out how to tell in
VBA whether it's checked or not. I reference the check box with: Sheets("Mysheet").Shapes("MyCheckBox") Can someone tell me the syntax to determine the check status? Thanks. John |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Checkbox from the Forms toolbar:
if worksheets("mySheet").checkboxes("myCheckbox").val ue = xlon then 'it's checked Checkbox from the Control toolbox toolbar: If Worksheets("mysheet").mycheckbox.Value = True Then 'it's checked robotman wrote: I have a checkbox on a worksheet but can't figure out how to tell in VBA whether it's checked or not. I reference the check box with: Sheets("Mysheet").Shapes("MyCheckBox") Can someone tell me the syntax to determine the check status? Thanks. John -- Dave Peterson |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
VBA whether it's checked or not.
I reference the check box with: Sheets("Mysheet").Shapes("MyCheckBox") Can someone tell me the syntax to determine the check status? I'm newly returned to Excel, so I'm not up-to-date on everything about it, so I'm not sure of you Shapes reference; but when I put a CheckBox on a work sheet, I do it from the Visual Basic ToolBox and draw it directly onto the sheet. I can then reference it directly within VBA using its name... and the property you want is the Value property. Use MyCheckBox.Value for code on the Worksheet itself. If you are referencing across Worksheets, then use Sheets("Mysheet").MyCheckBox.Value The Value property will be either True (if checked) or False (if not checked). Rick |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I meant objects from the *Control* tool box don't work on the Mac.
Rick, I'm also not able to create a check box from the VB Toolbox. When I click off a form in VB, the toolbox disappears. Thanks. John |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 a way to disable (gray out) checkboxes created from the Forms toolbox? ** so I'm not sure of you Shapes reference; but when I put a CheckBox on a work sheet, I do it from the Visual Basic ToolBox and draw it directly onto the When I click off a VB form, the VB ToolBox goes away. Are you talking about another toolbox like the Controls or Forms from the worksheet level or am I missing something? Thanks! John |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You can disable those checkboxes with something like:
ActiveSheet.CheckBoxes("check box 1").Enabled = False But they won't grey out. You may want to hide them??? ActiveSheet.CheckBoxes("check box 1").Visible = False 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 a way to disable (gray out) checkboxes created from the Forms toolbox? ** so I'm not sure of you Shapes reference; but when I put a CheckBox on a work sheet, I do it from the Visual Basic ToolBox and draw it directly onto the When I click off a VB form, the VB ToolBox goes away. Are you talking about another toolbox like the Controls or Forms from the worksheet level or am I missing something? Thanks! John -- Dave Peterson |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
(last post was something old... google burped!)
Dave... thanks for the macro suggestion. I like the generic "Application.Caller". John |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I meant objects from the *Control* tool box don't work on the Mac.
Rick, I'm also not able to create a check box from the VB Toolbox. When I click off a form in VB, the toolbox disappears. Thanks. John |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
all the check boxes should be checked if i check a particular checkbox in that row | Excel Programming | |||
Determine when checkbox is clicked | Excel Discussion (Misc queries) | |||
Checking the status of a checkbox in a user form | Excel Programming | |||
Syntax to check protected status of a worksheet? | Excel Discussion (Misc queries) | |||
Can't check ActiveX checkbox on worksheet | Excel Programming |