Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Find checkboxes and then check them
I am trying to loop through all the checkbox controls in a spreadsheet and
make sure they are all checked. Why is this not workin: Sub FindCheckboxes() Dim obj As OLEObject For Each obj In OLEObjects If TypeOf obj.Object Is msforms.CheckBox Then obj.Object.Value = True End If Next obj End Sub Thanks EM |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Find checkboxes and then check them
If the code is not behind the actual sheet you need to explicitly reference
the sheet -- Regards, Nigel "ExcelMonkey" wrote in message ... I am trying to loop through all the checkbox controls in a spreadsheet and make sure they are all checked. Why is this not workin: Sub FindCheckboxes() Dim obj As OLEObject For Each obj In OLEObjects If TypeOf obj.Object Is msforms.CheckBox Then obj.Object.Value = True End If Next obj End Sub Thanks EM |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Find checkboxes and then check them
Your code seems to work fine... as long as you are using ActiveX CheckBox'es
(that is, ones you got from the Visual Basic Toolbar). If you got your CheckBox'es from the Form's Toolbar, try this code... ActiveSheet.CheckBoxes.Value = True Rick "ExcelMonkey" wrote in message ... I am trying to loop through all the checkbox controls in a spreadsheet and make sure they are all checked. Why is this not workin: Sub FindCheckboxes() Dim obj As OLEObject For Each obj In OLEObjects If TypeOf obj.Object Is msforms.CheckBox Then obj.Object.Value = True End If Next obj End Sub Thanks EM |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Find checkboxes and then check them
sorry code to do it......
Sub FindCheckboxes() Dim obj As OLEObject With Sheets("Sheet1") For Each obj In .OLEObjects If TypeOf obj.Object Is MSForms.CheckBox Then obj.Object.Value = True End If Next obj End With End Sub -- Regards, Nigel "ExcelMonkey" wrote in message ... I am trying to loop through all the checkbox controls in a spreadsheet and make sure they are all checked. Why is this not workin: Sub FindCheckboxes() Dim obj As OLEObject For Each obj In OLEObjects If TypeOf obj.Object Is msforms.CheckBox Then obj.Object.Value = True End If Next obj End Sub Thanks EM |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Find checkboxes and then check them
Thanks to both of you. One last question. Is it possible to extract the
location of the objects. More specifically, can you extract which cell address or which row/col address the object is located by? Thanks RK "Rick Rothstein (MVP - VB)" wrote: Your code seems to work fine... as long as you are using ActiveX CheckBox'es (that is, ones you got from the Visual Basic Toolbar). If you got your CheckBox'es from the Form's Toolbar, try this code... ActiveSheet.CheckBoxes.Value = True Rick "ExcelMonkey" wrote in message ... I am trying to loop through all the checkbox controls in a spreadsheet and make sure they are all checked. Why is this not workin: Sub FindCheckboxes() Dim obj As OLEObject For Each obj In OLEObjects If TypeOf obj.Object Is msforms.CheckBox Then obj.Object.Value = True End If Next obj End Sub Thanks EM |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Unable to Check Checkboxes | Excel Discussion (Misc queries) | |||
How do I set Checkboxes where you can only check yes or no, not bo | Excel Worksheet Functions | |||
How do I check/uncheck ten or odd Checkboxes by click on one check | Excel Discussion (Misc queries) | |||
Link Checkboxes and Grey out the Check | Excel Programming | |||
Can't check checkboxes in userform ... sometimes | Excel Programming |