Find previous active cell

  • Thread starter Thread starter Otto Moehrbach
  • Start date Start date
O

Otto Moehrbach

Excel XP & Win XP
Is there a way to find the previous active cell? I want to use a
Worksheet_SelectionChange event macro to fire when a selection change is
made and then I want that macro to tell me the previous active cell. My end
goal is to force a tab sequence in a group of cells even when a cell entry
is not made. Thanks for your time. Otto
 
Perhaps something like this embedded directly in the sheet...

Private Sub Worksheet_Activate()
MsgBox "Current Address " & ActiveCell.Address
MsgBox "Last address " & LastCell.Address
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
MsgBox "Current Address " & Target.Address
MsgBox "Last address " & LastCell.Address
End Sub

Private Function LastCell() As Range
Static rngLastCell As Range

If rngLastCell Is Nothing Then Set rngLastCell = ActiveCell
Set LastCell = rngLastCell
Set rngLastCell = ActiveCell
End Function
 
Back
Top