ActiveX ToggleButton Reset

  • Thread starter Thread starter John
  • Start date Start date
J

John

I have a sheet with several hundred ActiveX Toggle buttons. After running
some code, I need to reset them all so their value = False. Is there a way to
do with with out typing out ToggleButtonX.Value = False 300+ times?

Thanks!
 
You could use a macro like:

Option Explicit
Sub testme02()
Dim OLEObj As OLEObject
Dim wks As Worksheet

Set wks = Worksheets("Sheet1")

For Each OLEObj In wks.OLEObjects
If TypeOf OLEObj.Object Is msforms.ToggleButton Then
OLEObj.Object.Value = False
End If
Next OLEObj

End Sub
 
You could use a macro like:

Option Explicit
Sub testme02()
Dim OLEObj As OLEObject
Dim wks As Worksheet

Set wks = Worksheets("Sheet1")

For Each OLEObj In wks.OLEObjects
If TypeOf OLEObj.Object Is msforms.ToggleButton Then
OLEObj.Object.Value = False
End If
Next OLEObj

End Sub
 
Try some code like


Sub ResetToggles()
Dim WS As Worksheet
Dim OleObj As OLEObject
Set WS = Worksheets("Sheet2")
For Each OleObj In WS.OLEObjects
If TypeOf OleObj.Object Is MSForms.ToggleButton Then
OleObj.Object.Value = False
End If
Next OleObj
End Sub

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
Try some code like


Sub ResetToggles()
Dim WS As Worksheet
Dim OleObj As OLEObject
Set WS = Worksheets("Sheet2")
For Each OleObj In WS.OLEObjects
If TypeOf OleObj.Object Is MSForms.ToggleButton Then
OleObj.Object.Value = False
End If
Next OleObj
End Sub

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 

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