Hi guys,
I am generating several checkboxes onto a workbook I have via VBA, but the issue I'm having is that the checkboxes are not aligning to the centre of the cells.
I was hoping someone could point me in the right direction with this. I have included a simple version of the code I am using to generate the checkboxes, and any help with aligning them to the center automatically would be much appreciated!
Thanks
I am generating several checkboxes onto a workbook I have via VBA, but the issue I'm having is that the checkboxes are not aligning to the centre of the cells.
I was hoping someone could point me in the right direction with this. I have included a simple version of the code I am using to generate the checkboxes, and any help with aligning them to the center automatically would be much appreciated!
Thanks
Code:
Sub CellCheckbox()
Dim myCell As Range
Dim myRng As Range
Dim CBX As CheckBox
With ActiveSheet
.CheckBoxes.Delete
Set myRng = .Range("A1:A10")
End With
For Each myCell In myRng.Cells
With myCell
Set CBX = .Parent.CheckBoxes.Add _
(Top:=.Top, _
Left:=.Left, _
Width:=.Width, _
Height:=.Height)
CBX.Name = "CBX_" & .Address(0, 0)
CBX.Caption = ""
CBX.Value = xlOff
CBX.LinkedCell = .Offset(0, 0).Address(external:=True)
.Offset(0, 1).NumberFormat = ";;;"
End With
Next myCell
End Sub