ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find previous active cell (https://www.excelbanter.com/excel-programming/412778-find-previous-active-cell.html)

Otto Moehrbach[_2_]

Find previous active cell
 
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



Jim Thomlinson

Find previous active cell
 
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
--
HTH...

Jim Thomlinson


"Otto Moehrbach" wrote:

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





All times are GMT +1. The time now is 12:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com