Center Checkbox
How do I write a procedure that centers a checkcox vertically in a cell?
|
Center Checkbox
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 -- Regards, Sébastien <http://www.ondemandanalysis.com <http://www.ready-reports.com "ranswert" wrote: How do I write a procedure that centers a checkcox vertically in a cell? |
Center Checkbox
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 "sebastienm" wrote: 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 -- Regards, Sébastien <http://www.ondemandanalysis.com <http://www.ready-reports.com "ranswert" wrote: How do I write a procedure that centers a checkcox vertically in a cell? |
Center Checkbox
You're right, wsh is not defined. So, instead of
Set chk = wsh.CheckBoxes.... use Set chk = cell.Parent.CheckBoxes.... -- Regards, Sébastien <http://www.ondemandanalysis.com <http://www.ready-reports.com "ranswert" wrote: 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 "sebastienm" wrote: 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 -- Regards, Sébastien <http://www.ondemandanalysis.com <http://www.ready-reports.com "ranswert" wrote: How do I write a procedure that centers a checkcox vertically in a cell? |
Center Checkbox
Works great
Thank you "sebastienm" wrote: You're right, wsh is not defined. So, instead of Set chk = wsh.CheckBoxes.... use Set chk = cell.Parent.CheckBoxes.... -- Regards, Sébastien <http://www.ondemandanalysis.com <http://www.ready-reports.com "ranswert" wrote: 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 "sebastienm" wrote: 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 -- Regards, Sébastien <http://www.ondemandanalysis.com <http://www.ready-reports.com "ranswert" wrote: How do I write a procedure that centers a checkcox vertically in a cell? |
All times are GMT +1. The time now is 01:41 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com