Referring to a user-selected range

J

James Mc

Can anyone advise how I can refer to a range in a spreadsheet that has
been selected by the user? Late in the macro, I need to loop through
all the cells in a range that the user selected earlier, and perform
an operation on each of them that depends on its location within the
range, but I can't figure out how to identify the range.

Thanks

James McIntosh
Australia
 
R

Rob van Gelder

James,

Sub testit()
Dim rng As Range

If TypeOf Selection Is Range Then
For Each rng In Selection
Debug.Print rng.Address
Next
End If
End Sub


Rob
 
Top