checkbox centered in cell

R

ranswert

I have the following code to add a checkbox in a cell and center it top to
bottom:

Set chk = cell.Parent.CheckBoxes.Add(cell.Left, cell.Top, 12, cell.Height)
chk as Excel.checkbox
cell as Range

This code works fine in one procedure, but in another one the checkbox is in
the bottom of the cell.

Any Ideas what to do to fix this?
Thanks
 
D

Dave Peterson

Depending on what the size of the cell is, you could play around with something
like:

Dim chk As CheckBox
Dim cell As Range

Set cell = ActiveSheet.Range("E7")

With cell
Set chk = .Parent.CheckBoxes.Add(Left:=.Left, _
Top:=.Top + (.Height / 4), _
Width:=.Width, _
Height:=.Height / 4)
End With
 

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

Top