Kelvin Stott
Active Member
- Joined
- Oct 26, 2010
- Messages
- 338
Hi,
I have written (adapted) the following code to turn specific cells into checkboxes, which works very nicely:
Now, I would like to automatically assign cells to a named "CheckBoxes" range just by copying an existing checkbox cell, without having to edit a named range of cells (or worse, define specific range addresses given that they may be moved around).
Is there any way to assign some kind of "tag" to a cell, so that it will automatically be assigned to a named range when moved or copied to another part of the sheet or workbook? Clearly, it would then need to work with the code above.
I would really appreciate any help, thanks!
I have written (adapted) the following code to turn specific cells into checkboxes, which works very nicely:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim CheckCells As Range, CheckCell As Range
Set CheckCells = Intersect(Target, Range("CheckBoxes"))
If Target.Cells.Count > 1 Then Exit Sub 'Remove this line to enable multi-select
If CheckCells Is Nothing Then Exit Sub
For Each CheckCell In CheckCells
If CheckCell = vbNullString Then
CheckCell = "a"
Else
CheckCell = vbNullString
End If
Next CheckCell
End Sub
Now, I would like to automatically assign cells to a named "CheckBoxes" range just by copying an existing checkbox cell, without having to edit a named range of cells (or worse, define specific range addresses given that they may be moved around).
Is there any way to assign some kind of "tag" to a cell, so that it will automatically be assigned to a named range when moved or copied to another part of the sheet or workbook? Clearly, it would then need to work with the code above.
I would really appreciate any help, thanks!