Format control with check boxes

newmlong

New Member
Joined
Jul 19, 2011
Messages
1
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
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Forum statistics

Threads
1,224,603
Messages
6,179,849
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top