Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Previously active cell reference

Status
Not open for further replies.

ETID

Programmer
Jul 6, 2001
1,867
US
How do I capture the cell reference of the previously active cell?

In a macro that launches on an event, either (change or selection)

If the active cell is C3 and I press "Arrow", "Tab" or "Enter", I want to be able to pick up the "C3" cell ref. of the cell that I just moved from.

 
There's probably a better way, but here's one possibility - since you already use a Worksheet_SelectionChange event handler, you could have a static variable that holds the last active cell, by putting at the end of that event handler:

LastAddress=target.address

Then you can refer to the LastAddress variable when you need to return to the previous cell.
Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top