Add a checkbox through VBA

tlindeman

Active Member
Joined
Jun 29, 2005
Messages
313
Good afternoon,
I need to add multiple checkboxes to various cells, my question is how do I do that in VBA? My sheet name is "CHECKLIST" and I need to add it to multiple cells in column A. I found a simlar post ,however that person wanted to add it to every cell in a column, Ineed to add it to specific cells and make the reference to that particular cell.

Thank You
Tony
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Hi Tony,

You should be able to change the range in the code you found to address only the cells you're interested in. It doesn't have to be a contiguous block.

Here's a sample.

Gary

Code:
Public Sub Test()

Dim oCell As Range
Dim oRange As Range
Dim oCheck As CheckBox

Set oRange = ActiveSheet.Range("A10, A12:A15, A18, A21:A24, A27, A29")

For Each oCell In oRange
    Set oCheck = ActiveSheet.CheckBoxes.Add(oCell.Left, oCell.Top, 80, 15)
    oCheck.LinkedCell = oCell.Offset(0, 2).Address
Next oCell


End Sub
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

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