lundi 25 avril 2022

How do I link my first check box with the appropriate row

I'm attempting to write a vba that automatically links checkboxes to the appropriate rows. I wrote the following

Sub LinkChecklist()

Dim chk As CheckBox

For Each chk In ActiveSheet.CheckBoxes
    chk.LinkedCell = chk.TopLeftCell.Offset(0, 1).Address
Next

End Sub

however when I run the code, the first checkbox which starts on row 2 col F, links to row 1 col G when it should be linking to row 2. This makes it so that some of the checkboxes below it link to the wrong cells also. Any tips on how to resolve that issue?

Also, would appreciate any tips on making sure that each row contains only one check box. As you can see in the image, the more text there is in a cell, the more the checkboxes get messed up. Is there any way to make it so that each row, no matter how large or small it gets, contains only one checkbox?

Thanks

image of checkboxes




Aucun commentaire:

Enregistrer un commentaire