PDA

View Full Version : [SOLVED] create a new checkbox and assign its ID?



next
01-14-2014, 10:46 AM
How do I assign an ID to a checkbox?

With ActiveSheet
.CheckBoxes.Add(740, 270, 75, 15).Select
.CheckBoxes.Add(Cells(r, "L").Left + 20, Cells(r, "L").Top, 85, 15).Text = "Continuous"
End With
Right now VBA is using default CheckBox1, 2, 3, etc., but I need to be more specific.

Kenneth Hobs
01-14-2014, 01:18 PM
Not sure what you mean by ID. This shows how to set the Name and Text properties.


Sub k()
With ActiveSheet
Dim r As Long, cb As Object
r = 17
Set cb = .CheckBoxes.Add(740, 270, 75, 15)
cb.Name = "cb 1"
cb.Text = "Ken's cb 1"
Set cb = .CheckBoxes.Add(Cells(r, "L").Left + 20, Cells(r, "L").Top, 85, 15)
cb.Name = "cb 2"
cb.Text = "Ken's cb 2"
End With
End Sub

next
01-14-2014, 03:05 PM
Exactly what I was looking for, thank you!