Sub Insert_Form_Checkboxes()
Dim myCell As Range, myRng As Range
Dim CBX As CheckBox
With ActiveSheet
.CheckBoxes.Delete
Set myRng = .Range("o3:as15")
End With
Application.ScreenUpdating = False
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
CBX.OnAction = "RunForAllChkBoxes"
.NumberFormat = ";;;"
.Interior.ColorIndex = 56
End With
Next myCell
Application.ScreenUpdating = True
End Sub
Sub RunForAllChkBoxes()
Dim fromWhere As String
With ActiveSheet.CheckBoxes(Application.Caller)
fromWhere = Split(Application.Caller, "_")(1)
If .Value = xlOff Then
Range(fromWhere).Interior.ColorIndex = 56
Else
Range(fromWhere).Interior.ColorIndex = 4
End If
End With
End Sub