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

This is what I actually implemented:

Put this in Microsoft Excel Objects ThisWorkbook
Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
PrvusActvSht = Sh.Name
End Sub

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

'Put this in a module:
Sub SetActiveCellLocOnAllSheets()
On Error GoTo Error1

MyMsg = vbCr & " This will set the active cell location for all Sheets
to the same cell." & _
vbCr & vbCr & vbCr & "Enter the cell you wish to be active (ie: U4)"

MyTitle = "Set Active Cell Location"

Application.ScreenUpdating = False

HomeSht = PrvusActvSht
Worksheets(PrvusActvSht).Activate
PrevCell = ActiveCell.Address(RowAbsolute:=False, ColumnAbsolute:=False)

HomeCell = InputBox(MyMsg, MyTitle, PrevCell)

If HomeCell = "" Then GoTo Error1


For WkSht = 1 To 24
Worksheets(WkSht).Select
Range(HomeCell).Select
ActiveWindow.ScrollRow = ActiveCell.Row
Next WkSht


Exit1:
Application.ScreenUpdating = True
Worksheets(HomeSht).Select
Exit Sub

Error1:
Worksheets(HomeSht).Select
Application.ScreenUpdating = True
End Sub

To use, put a button on one of the worksheets and set the code to call
SetActiveCellLocOnAllSheets

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
Code for Returning to Last Active Worksheet Please Garry Excel Programming 0 February 27th 07 04:10 PM
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


All times are GMT +1. The time now is 08:49 AM.

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"