View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tim Zych Tim Zych is offline
external usenet poster
 
Posts: 389
Default Extracting proper range address from multiple cell selections in V

When Areas.Count = 1, the range is contiguous.

Dim rng as Range
Set rng = Range("C3, D3")
debug.print rng.areas.count
debug.print rng.Address(0,0)



--
Tim Zych
SF, CA

"ExcelMonkey" wrote in message
...
Is there a way in VBA to ascertain if a range selection is contiguous.
That
is, say I select C3 and D4 on the same page. The Address property for the
Selection does not automatically put the address into the form C3:D3 but
instead into the form $C$3,$D$3. Is there a way to do this in VBA or do
I
have to write a function which tests the string for contiguous row or
column
headers?

Sub Macro1()
Dim RngAddress As String
Range("C3,D3").Select
RngAddress = Selection.Address
Debug.Print RngAddress
End Sub

Immediate Window:
$C$3,$D$3

Thanks

EM