checkboxes

  • Thread starter Thread starter marksuza
  • Start date Start date
M

marksuza

Hi, I was wondering if you guys could help me with something. I have t
create a column with several checkboxes, all linked to a respectiv
cell. My idea is something like this:

count=1
cell=1

Do

create checkbox in 'A'cell
link checkbox to 'A'cell

count= count +1
cell = cell +1

while count <> 1000

Can anyone help me with the syntax?

Thanks a lot

Mar
 
Sub Macro1()
' clear existing checkboxes
ActiveSheet.CheckBoxes.Delete
For Each cell In Range("A1:A1000")
With ActiveSheet.CheckBoxes.Add( _
cell.Left, cell.Top, cell.Width, cell.Height)
.LinkedCell = cell.Address(external:=True)
.Caption = ""
End With
Next
End Sub


Uses checkboxes from the forms toolbar.
 
This uses the Checkbox from the Forms toolbar. I don't recommend the one
on the Controls toolbar because it tends to be very buggy - especially
when using large numbers. Amend as necessary.

'---------------------------------------------
Sub MAKE_CHECKBOXES()
Dim CB As Integer
Dim CBox As Object
Dim CBcount As Long
Dim CBtop As Double
Dim CBlink As String
'------------------------------------------
CBcount = ActiveSheet.CheckBoxes.Count
For CB = CBcount + 1 To 10
CBtop = CB * 25
CBlink = "A" & CB
ActiveSheet.CheckBoxes.Add 50, CBtop, 60, 20
Set CBox = ActiveSheet.CheckBoxes(CB)
With CBox
Text = "MyBox" & CB
Value = xlOff
LinkedCell = CBlink
Interior.ColorIndex = 40
Border.LineStyle = msoLineSingle
Border.Weight = xlMedium
Display3DShading = True
End With
Next
End Sub
'--------------------------------------------
 
Back
Top