Center Checkbox

  • Thread starter Thread starter ranswert
  • Start date Start date
R

ranswert

How do I write a procedure that centers a checkcox vertically in a cell?
 
Hi,
Try something like:

Dim cell as Range
Dim chk as Excel.Checkbox

Set cell=activecell
Set chk = wsh.CheckBoxes.Add(cell.Left + 0.3 * cell.Width, cell.Top,
cell.Width, cell.Height)
chk.Height = cell.Height - 1.5
 
I copied the code that you suggested and I got a run time error object
required message. This is the code I entered:

Sub cbox()
Dim cell As Range
Dim chk As Excel.CheckBox
Set cell = ActiveCell
Set chk = wsh.CheckBoxes.Add(cell.Left + 0.3 * cell.Width, cell.Top,
cell.Width, cell.Height)
chk.Height = cell.Height - 1.5

End Sub

Thanks
 
You're right, wsh is not defined. So, instead of
Set chk = wsh.CheckBoxes....
use
Set chk = cell.Parent.CheckBoxes....
 

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

Back
Top