Macro for returning to the previously selected cell
Give the following a try. Add a Module to your project and copy/paste these
declarations into its code window...
Public OldCell As Range
Public OldSheet As Object
Next, double click the ThisWorkbook entry in the Project list and copy/paste
this code into its code window....
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, _
ByVal Target As Range)
Set OldCell = Target
Set OldSheet = Sh
End Sub
Finally, use the following in your own subroutine or function...
Sub YourSubroutine()
Dim SavedOldSheet As Object
Dim SavedOldCell As Range
Set SavedOldCell = OldCell
Set SavedOldSheet = OldSheet
'
' <<< Place your own code here
'
SavedOldSheet.Activate
SavedOldSheet.Range(SavedOldCell.Address).Select
End Sub
Rick
"Mike C" wrote in message
...
Hello - I am trying to figure out how to create a macro that will
allow me to jump to my prior location in a workbook.
For example, I will be in Sheet1:A35, then I will need to go to
Sheet5:D73. What I am trying to do is come up with a shortcut to
immediately jump back to Sheet1:A35.
Does anyone have some code put together that does this?
Thanks for any suggestions!
- F
|