Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
format checkbox
I want to center checkboxes I have added in the middle of a cell. Can I do
that? Here is my code... Option Explicit Sub addCBX() Dim myCBX As CheckBox Dim myCell As Range Dim RAN As Range Set RAN = ActiveCell With ActiveSheet .CheckBoxes.Delete For Each myCell In RAN With myCell Set myCBX = .Parent.CheckBoxes.Add _ (Top:=.Top, Width:=.Width, _ Left:=.Left, Height:=.Height) With myCBX .LinkedCell = myCell.Offset(0, 7).Address(external:=True) .Caption = "" .Name = "CBX_" & myCell.Address(0, 0) '.OnAction = "'" & ThisWorkbook.Name & "'!dothework" End With .NumberFormat = ";;;" End With Next myCell End With End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
format checkbox
This seemed to work ok for me:
Set myCBX = .Parent.CheckBoxes.Add _ (Top:=.Top, _ Width:=24, _ Left:=.Left + ((.Width - 24) / 2), _ Height:=.Height) You could fiddle with that width if it's off a bit. John wrote: I want to center checkboxes I have added in the middle of a cell. Can I do that? Here is my code... Option Explicit Sub addCBX() Dim myCBX As CheckBox Dim myCell As Range Dim RAN As Range Set RAN = ActiveCell With ActiveSheet .CheckBoxes.Delete For Each myCell In RAN With myCell Set myCBX = .Parent.CheckBoxes.Add _ (Top:=.Top, Width:=.Width, _ Left:=.Left, Height:=.Height) With myCBX .LinkedCell = myCell.Offset(0, 7).Address(external:=True) .Caption = "" .Name = "CBX_" & myCell.Address(0, 0) '.OnAction = "'" & ThisWorkbook.Name & "'!dothework" End With .NumberFormat = ";;;" End With Next myCell End With End Sub -- Dave Peterson |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
format checkbox
Thanks again Dave, your a champ!
"Dave Peterson" wrote: This seemed to work ok for me: Set myCBX = .Parent.CheckBoxes.Add _ (Top:=.Top, _ Width:=24, _ Left:=.Left + ((.Width - 24) / 2), _ Height:=.Height) You could fiddle with that width if it's off a bit. John wrote: I want to center checkboxes I have added in the middle of a cell. Can I do that? Here is my code... Option Explicit Sub addCBX() Dim myCBX As CheckBox Dim myCell As Range Dim RAN As Range Set RAN = ActiveCell With ActiveSheet .CheckBoxes.Delete For Each myCell In RAN With myCell Set myCBX = .Parent.CheckBoxes.Add _ (Top:=.Top, Width:=.Width, _ Left:=.Left, Height:=.Height) With myCBX .LinkedCell = myCell.Offset(0, 7).Address(external:=True) .Caption = "" .Name = "CBX_" & myCell.Address(0, 0) '.OnAction = "'" & ThisWorkbook.Name & "'!dothework" End With .NumberFormat = ";;;" End With Next myCell End With End Sub -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
In Excel how does one the format/size of a checkbox | Excel Discussion (Misc queries) | |||
Format Checkbox text | Excel Discussion (Misc queries) | |||
How to have Checkbox A uncheck with checked Checkbox B | Excel Discussion (Misc queries) | |||
format an entire column to contain checkbox activex control | New Users to Excel | |||
checkbox on form reset from checkbox on sheet | Excel Programming |