Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with sebastienm's code - Returning To Previously Selected Worksheet
Hi all, I'm trying to utilise the following code detailed by sebastienm in this post, http://www.excelforum.com/showthread...rning+previous However once complete and I have tried to test the Macro the following error is returned - "Run time error 91 - Object variable or with block variable not set" In debug the following piece of code from the second module is highlighted - "Tracker.GotoLastSheet" Can anyone help me in working out where I have gone wrong? I am a relative novice in this area so apologies if it is a obvious mistake on my half. Many Thanks in advance, AcesUp - CLASS MODULE- ' ------------------------------------------------------ Option Explicit Private WithEvents App As Application Private mLastSheet As Object '------------------------------------ Public Property Get LastSheet() As Object Dim s As String If mLastSheet Is Nothing Then Set LastSheet = Nothing Else On Error Resume Next 'capture automation error if book has been closed s = mLastSheet.Name If Err < 0 Then Set mLastSheet = Nothing Set LastSheet = Nothing Else Set LastSheet = mLastSheet End If End If End Property Public Sub GotoLastSheet() If Not LastSheet Is Nothing Then On Error Resume Next 'if hidden book or other error LastSheet.Parent.Activate LastSheet.Activate End If End Sub '------------------------------------ Private Sub App_SheetDeactivate(ByVal Sh As Object) Set mLastSheet = Sh End Sub Private Sub Class_Initialize() Set App = Application End Sub Private Sub Class_Terminate() Set App = Nothing End Sub '----------------------------------------------------- -REGULAR MODULE- '---------------------------------------------------- Option Explicit Public Tracker As ClsSheetTracker Sub GotoLast() Tracker.GotoLastSheet End Sub '---------------------------------------------------- -- AcesUp ------------------------------------------------------------------------ AcesUp's Profile: http://www.excelforum.com/member.php...o&userid=26519 View this thread: http://www.excelforum.com/showthread...hreadid=548251 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Returning To Previous Worksheet - Help with sebastienm's code | Excel Discussion (Misc queries) | |||
Macro to concatenate previously selected cells | Excel Programming | |||
Clearing what you have previously selected | Excel Programming | |||
Lookup Oldest date from previously selected Group Data | Excel Worksheet Functions | |||
Selection the previously selected cell | Excel Programming |