ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   checkbox centered in cell (https://www.excelbanter.com/excel-programming/407445-checkbox-centered-cell.html)

ranswert

checkbox centered in cell
 
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

Dave Peterson

checkbox centered in cell
 
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



ranswert wrote:

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


--

Dave Peterson

ranswert

checkbox centered in cell
 
Thanks
I'll give that a try.

Any idea it works in one procedure, but not another?

"Dave Peterson" wrote:

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



ranswert wrote:

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


--

Dave Peterson


Dave Peterson

checkbox centered in cell
 
Maybe 12 is too big.



ranswert wrote:

Thanks
I'll give that a try.

Any idea it works in one procedure, but not another?

"Dave Peterson" wrote:

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



ranswert wrote:

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


--

Dave Peterson


--

Dave Peterson

ranswert

checkbox centered in cell
 
Thanks

"Dave Peterson" wrote:

Maybe 12 is too big.



ranswert wrote:

Thanks
I'll give that a try.

Any idea it works in one procedure, but not another?

"Dave Peterson" wrote:

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



ranswert wrote:

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

--

Dave Peterson


--

Dave Peterson



All times are GMT +1. The time now is 12:20 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com