I'm using a code that works well adding check boxes where I need them. The issue is that with all the boxes required I need the cell linked at the same time. I know that there is probably a line (linkedcell) missing from my code and due to my lack of knowledge I would greatly appreiciate some help.
This is being used with excel 2003
Sub AddCheckBoxToCell(Ref_Cell As Range)
Dim ChkBox As CheckBox
Dim N As Double
With Ref_Cell.Cells(1, 1)
refLeft = .Left
refTop = .Top
refHeight = .Height
End With
Set ChkBox = ActiveSheet.CheckBoxes.Add(10, 10, 15, 12)
N = (refHeight - ChkBox.Height) / 2#
With ChkBox
.Caption = ""
.Top = refTop + N
.Left = refLeft
.OnAction = ""
End With
End Sub
Sub AddCheckBoxes()
Dim BoxCol As Variant
Dim CtrlCol As Variant
Dim LastRow As Long
Dim R As Long
Dim StartRow As Long
BoxCol = "O" 'Column where Check Box is inserted
CtrlCol = "B" 'Column that controls if Check Box is inserted
StartRow = 1
LastRow = Cells(Rows.Count, CtrlCol).End(xlUp).Row
For R = StartRow To LastRow
If Cells(R, CtrlCol) <> "" Then
AddCheckBoxToCell Cells(R, BoxCol)
End If
Next R
End Sub
This is being used with excel 2003
Sub AddCheckBoxToCell(Ref_Cell As Range)
Dim ChkBox As CheckBox
Dim N As Double
With Ref_Cell.Cells(1, 1)
refLeft = .Left
refTop = .Top
refHeight = .Height
End With
Set ChkBox = ActiveSheet.CheckBoxes.Add(10, 10, 15, 12)
N = (refHeight - ChkBox.Height) / 2#
With ChkBox
.Caption = ""
.Top = refTop + N
.Left = refLeft
.OnAction = ""
End With
End Sub
Sub AddCheckBoxes()
Dim BoxCol As Variant
Dim CtrlCol As Variant
Dim LastRow As Long
Dim R As Long
Dim StartRow As Long
BoxCol = "O" 'Column where Check Box is inserted
CtrlCol = "B" 'Column that controls if Check Box is inserted
StartRow = 1
LastRow = Cells(Rows.Count, CtrlCol).End(xlUp).Row
For R = StartRow To LastRow
If Cells(R, CtrlCol) <> "" Then
AddCheckBoxToCell Cells(R, BoxCol)
End If
Next R
End Sub