I've created some checkboxes on a worksheet.
I need to write some code to remove the check in the checkboxes.
Can anyone tell me how I call the checkboxes in VBA, and remove the check mark?
Thanks
I've created some checkboxes on a worksheet.
I need to write some code to remove the check in the checkboxes.
Can anyone tell me how I call the checkboxes in VBA, and remove the check mark?
Thanks
[vba]Sub ResetAllCheckBoxesInUserForm()
Dim ctrl As Control
For Each ctrl In UserForm1.Controls
If TypeName(ctrl) = "CheckBox" Then
ctrl.Value = False
End If
Next ctrl
End Sub[/vba]
This works on a userform. Change the userform1 to the sheet where you have the checkboxes:
[VBA] ActiveWorkbook.Sheets("shtname").Controls[/VBA]
Steve
"Nearly all men can stand adversity, but if you want to test a man's character, give him power."
-Abraham Lincoln
The checkboxes aren't on a userform, they are on a worksheet called "SOP"
I'm getting a runtime error: Object doesn't support this property or method.
Im using Excel 2003.
Last edited by ukdane; 02-06-2009 at 09:42 AM. Reason: Code in reply doesn't work
I'm sorry, I need more coffee this morning. Are they activeX checkboxes or are they from the forms toolbar?
Steve
"Nearly all men can stand adversity, but if you want to test a man's character, give him power."
-Abraham Lincoln
They are from the forms toolbar.
[vba]
Dim cb As CheckBox
For Each cb In ActiveSheet.CheckBoxes
cb.Delete
Next cb
Dim cb As CheckBox
[/vba]
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
or
[VBA]cb.Value = False[/VBA]
if you just want to clear the checkmark
Steve
"Nearly all men can stand adversity, but if you want to test a man's character, give him power."
-Abraham Lincoln
Super, thanks.