PDA

Click to See Complete Forum and Search --> : Checkbox in Worksheet Cell


Mindcrime
Apr 15th, 2004, 06:32 AM
Can anyone help me with code to Embed a Checkbox control into a Cell in an Excel Worksheet?

Thanks

BrianB
Apr 15th, 2004, 07:06 AM
There are 2 sorts of checkbox, from Forms toolbar or Controls toolbar. The latter have more properties but can become very buggy at times. Avoid if possible.


'- checkbox from Forms
ActiveSheet.CheckBoxes.Add(55.5, 60.75, 77.25, 18.75).Select

'- Checkbox from Controls
ActiveSheet.OLEObjects.Add(ClassType:="Forms.CheckBox.1", _
Link:=False, DisplayAsIcon:=False, Left:=57, _
Top:=103.5, Width:=69.75, Height:=18).Select

Mindcrime
Apr 15th, 2004, 07:47 AM
Thanks for that.

Which cell is it contained in?

Sorry, but I have already tried that and resizing the row/col will not resize the control held in the cell (or which actually floats above the spreadsheet).

Mindcrime
Apr 15th, 2004, 09:14 AM
:blush:

Whoops

That was slightly different to the one I tried and it does actually work, much to my embrassment!

Technically, this would be better...

ActiveSheet.CheckBoxes.Add(Cells(1,2).Left, Cells(1, 2).Top, 10, 10).Select


Thanks again.