View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default how to get the last range address (not the last cell)

Hi,

Try this. You don't of course need the message box that's just to
demonstrate it's working. Right click your sheet tab, view code and paste the
code in

Private lastRange As Range

Private Sub Worksheet_Activate()
Set lastRange = ActiveCell
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
MsgBox "Last selected cell was " & lastRange.Address & Chr(10) _
& "Current cell is " & Target.Address
Set lastRange = Target
End Sub


Mike

"filo666" wrote:

Hi, I found several posts indicating how to get the last cell, however I
would like to get the last selected range,

ej.

I select range A1:F2, then I select cell J3, I would like to get a variable
with the A1:F2 address after I selected the cell J3.

Thanks