ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Center Checkbox (https://www.excelbanter.com/excel-programming/403344-center-checkbox.html)

ranswert

Center Checkbox
 
How do I write a procedure that centers a checkcox vertically in a cell?

sebastienm

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?


ranswert

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?


sebastienm

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?


ranswert

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