Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to link all Check Boxes on a Sheet to their Cell

Status
Not open for further replies.

deemsla

Programmer
Jan 28, 2003
1
BE
I'm having troubles with creating a sheet, containing hundreds of Check Boxes. I would like to create a macro that links every existing Check Box (property 'Move but don't size with cells' selected) to the Cell on which it is placed.
Can anyone tell me how?
 
Hiya deemsla,

I think you're using the checkbox from the FORMS toolbar which is part of the Checkboxes collection. In that case try the following code which'll use the property
Code:
TopLeftCell.Address
to link to the checkbox:

Code:
    Dim l_wksSheetToChange As Worksheet
    Dim l_chkCheckbox As CheckBox
    
    Set l_wksSheetToChange = ThisWorkbook.Sheets(1)
    
    For Each l_chkCheckbox In l_wksSheetToChange.CheckBoxes
        l_chkCheckbox.Placement = xlMove
        l_chkCheckbox.LinkedCell = l_chkCheckbox.TopLeftCell.Address
    Next l_chkCheckbox


HTH

Cheers
Nikki
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top