PDA

View Full Version : Solved: Check Box



ukdane
02-06-2009, 09:28 AM
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

lucas
02-06-2009, 09:35 AM
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

This works on a userform. Change the userform1 to the sheet where you have the checkboxes:

ActiveWorkbook.Sheets("shtname").Controls

ukdane
02-06-2009, 09:37 AM
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.

lucas
02-06-2009, 09:56 AM
I'm sorry, I need more coffee this morning. Are they activeX checkboxes or are they from the forms toolbar?

ukdane
02-06-2009, 09:59 AM
They are from the forms toolbar.

Bob Phillips
02-06-2009, 10:16 AM
Dim cb As CheckBox

For Each cb In ActiveSheet.CheckBoxes

cb.Delete
Next cb
Dim cb As CheckBox

lucas
02-06-2009, 10:22 AM
or
cb.Value = False
if you just want to clear the checkmark

ukdane
02-06-2009, 10:47 AM
Super, thanks.