View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
dev dev is offline
external usenet poster
 
Posts: 66
Default Cell address in a given selection range. Help please!!

The below sub is returning correct cellAddress
==============================
Sub Macro1()
Dim cell As Range
Dim cellAddress As String
For Each cell In Range("B1:C3")
cellAddress = cell.Address(Null, Null, xlA1, Null, Null)
MsgBox (cellAddress)
Next
End Sub

But this is not working - Can't I loop thru the Range like
below?========================================
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim cell As Range
Dim cellAddress As String
For Each cell In Range
cellAddress = cell.Address(Null, Null, xlA1, Null, Null)
MsgBox (cellAddress)
Next
End Sub


"Dev" wrote:

I have a method which returns Excel selection Range using get_Address()
method. I am tyring to return all the cells in that selection range.

Ex: If I have selection Range from $A$1:$B$2 (this is my input) then I want
to output
$A$1
$A$2
$B$1
$B$2

Is it possible to achieve this using Excel OM?