I have got another challenge now though I need to place multiple rows so when I change the RANGE to, for example J6:DG100 it crashes VBA and excel. Any tricks to get this working for me?
Sub Add_Checkboxes_Across()
Dim myCBX As CheckBox
Dim myCell As Range
Dim RAN As Range
'Sheets.Add 'for testing
Set RAN = ActiveSheet.Range("J6:DG6")
Application.ScreenUpdating = False
With ActiveSheet
.CheckBoxes.Delete
For Each myCell In RAN
With myCell
.RowHeight = 24
.Offset(0, 0).RowHeight = 24
.Offset(0, 0).VerticalAlignment = xlDistributed
.Offset(0, 0).HorizontalAlignment = xlCenter
.Offset(0, 0).RowHeight = 24
Set myCBX = .Parent.CheckBoxes.Add _
(Top:=.Top, _
Width:=12, _
Left:=.Left + ((.Width - 12) / 2), _
Height:=.Height)
With myCBX
.LinkedCell = myCell.Offset(0, 0).Address(external:=True)
.Caption = ""
.Value = xlOff
End With
End With
Next myCell
With Range("J6:DG6")
.HorizontalAlignment = xlCenter
End With
End With
Application.ScreenUpdating = True
End Sub
Bookmarks