Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Code for Returning to Last Active Worksheet Please

I needed similar capablities but did not want to use a worksheet to hold the
"Previous ActiveSheet" name.

The following code works as well:

'Put this at the top of a module window
Global PrvusActvSht As String

'Put this in every worksheet in the workbook
Private Sub Worksheet_Deactivate()
PrvusActvSht = Me.Name
End Sub

'Now PrvusActvSht will always = the "Previous ActiveSheet" name.

'Just use:
worksheets(PrvusActvSht).select
'to get bact to the "Previous ActiveSheet"

Thanks to all for leading toward a solution!!

"Carl" wrote:

Can anyone tell me the code to use in a macro to return the user to the last
active worksheet? The user is being sent to a worksheet containing
instructions but needs to be able to return to the last worksheet visited.
"ActiveSheet.Previous.Select" did not work. Thanks in advance.

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
What is the code for the active worksheet? Dr Dan[_2_] Excel Discussion (Misc queries) 12 February 23rd 07 03:12 PM
Code for Returning to Last Active Worksheet Please Don Guillett Excel Programming 2 December 5th 06 06:11 PM
Returning To Previous Worksheet - Help with sebastienm's code AcesUp Excel Discussion (Misc queries) 0 June 3rd 06 12:47 PM
Altering code to reference the worksheet before the active worksheet KimberlyC Excel Programming 8 March 15th 05 10:26 PM
VBA code that only runs when a worksheet is active Paul James[_3_] Excel Programming 4 December 11th 03 01:05 AM


All times are GMT +1. The time now is 11:13 PM.

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

About Us

"It's about Microsoft Excel"