Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with sebastienm's code - Returning To Previously Selected Worksheet AcesUp Excel Programming 0 June 4th 06 10:44 AM
Macro to concatenate previously selected cells Grumpy Excel Programming 1 November 22nd 05 02:42 PM
Clearing what you have previously selected T8RSP[_4_] Excel Programming 1 November 7th 05 10:28 AM
referencing previously selected cells after macro execution begins Glenn Excel Programming 5 October 15th 04 12:52 AM
Selection the previously selected cell David Excel Programming 3 June 3rd 04 02:16 PM


All times are GMT +1. The time now is 10:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"