Jac,
Try something like
Dim Ar As Range
For Each Ar In Selection.Areas
Debug.Print Ar.Address
Next Ar
Why, in VBA, when I type "Selection" followed by a dot, I do
not get any option suggested.
The reason is that Selection is a generic Object, not a specific
type of object. It usually refers to a range of cells, but may
refer to a ChartObject, a Shape, or whatever happens to be
selected at run time. When you are writing code, the editor has
no idea what type of object might be selected, so no Intellisense
is provided.
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
"Jac Tremblay" wrote in
message
...
Hi everyone,
I'm trying to find a way to loop on every area in a multiple
selection and the help provided is rather concise:
' *****
Sub NoMultiAreaSelection()
NumberOfSelectedAreas = Selection.Areas.Count
If NumberOfSelectedAreas 1 Then
MsgBox "You cannot carry out this command on multi-area
selections"
End If
End Sub
' *****
I would like to get some information like the area's address
for each area in the current selection. Something like this:
*****
Sub MultiAreaSelection()
Dim NumberOfSelectedAreas As Integer, intI As Integer
NumberOfSelectedAreas = Selection.Areas.Count
For intI = 1 To NumberOfSelectedAreas
'How can I get each area's address, for example?
Next intI
End Sub
' *****
Another question about Selection:
Why, in VBA, when I type "Selection" followed by a dot, I do
not get any option suggested. The same as when an object is
declared as Object, a too general object?
Thanks to anyone who can help.