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

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