ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cycle through all Checkboxes on a worksheet (https://www.excelbanter.com/excel-programming/394515-cycle-through-all-checkboxes-worksheet.html)

the00snoopy

Cycle through all Checkboxes on a worksheet
 
I would like to create a macro that will find all the checkbox controls (they
are all directX) on a worksheet and then check each one. If it is checked, I
would like it to run a macro with a name identical to the caption on the
checkbox.

How would I go about searching for checkboxes and compsosing a list of them?

Jim Thomlinson

Cycle through all Checkboxes on a worksheet
 
Something like this perhaps...
Sub FindCheckboxes()
Dim obj As OLEObject

For Each obj In OLEObjects
If TypeOf obj.Object Is msforms.CheckBox Then
If obj.Object.Value = True Then Application.Run obj.Object.Caption
End If
Next obj
End Sub
--
HTH...

Jim Thomlinson


"the00snoopy" wrote:

I would like to create a macro that will find all the checkbox controls (they
are all directX) on a worksheet and then check each one. If it is checked, I
would like it to run a macro with a name identical to the caption on the
checkbox.

How would I go about searching for checkboxes and compsosing a list of them?



All times are GMT +1. The time now is 05:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com