View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default Referencing checkboxes on a worksheet from a form

Brian,
Like this ?

Private Sub CommandButton1_Click()
With Worksheets(1)
.OLEObjects("CheckBox1").Delete
End With
End Sub

For the 2nd part, record a macro whilst you add a check box to get something
like:

ActiveSheet.OLEObjects.Add(ClassType:="Forms.Check Box.1", Link:=False, _
DisplayAsIcon:=False, Left:=373.5, Top:=165.75, Width:=63.75, Height
_
:=20.25).Select

Combine this with the _Click event of your existing Checkbox.
Presumable you would need to delete it also if the check box is then
unchecked, otherwise the user will become confused; or do not use a check
box for this action.

NickHK

"Brian" wrote in message
...
Hi,

I am trying to figure out how to reference some checkboxes directly placed
on a worksheet from code attached to a form. In other words, I want to

click
a button on a form and tell it to remove some checkboxes on sheet. To
clarify that...yes I do want to "remove" the checkboxes, not simply to
uncheck them.

A second question: is there any way to allow a user to tick some

checkboxes
on a form, and then new checkboxes will be automatically created on the
worksheet for those ticked items only?

I am new to VBA. Any help would be most appreciated.

Best regards,
Brian.