Identify multiple selected cells


Posted by Erica on August 14, 2000 11:19 PM

I want to identify multiple selected cells within a macro (alternative is to use a drop down list box with multiple select option set, but I can also not figure out how to identify which was selected, and this is not the first choice). I typically want to check a fixed range by running through the cells in a loop and check if each cell is selected or not ie. cells(r,c).selected = true. How can this be done? There is no property .selected.



Posted by Celia on August 15, 0100 1:10 AM


If the range you want to check is A1:D15 :-

1.If you want to identify the selected cells one at a time :-
Dim cell As Range
For Each cell In Range("A1:D15")
If Not Intersect(cell, Range("A1:D15")) Is Nothing Then
MsgBox cell.Address
End If
Next

2.If you want to identify all selected cells :-Dim sel As Range
Set sel = Intersect(Range("A1:D15"), Selection)
MsgBox sel.Address(False, False)

Celia