Hi,
I have a workbook with 17 sheets.Each sheet is linked with formula.I am looking for a macro to return to the previously viewed sheet.Say i moved from sheet 1 to Sheet 7 ,is there a way i can again return back to sheet 1 from sheet 7 by running a macro.
Regards,
Sudarshan
macro to return user to the previously viewed sheet
-
-
-
Re: macro to return user to the previously viewed sheet
Hi
I use the following to move one sheet at a time. You may be able to adapt it.
Code
Display MoreSub NextSheet() Application.ScreenUpdating = False ActiveSheet.Next.Select Application.ScreenUpdating = True End Sub Sub Previous() Application.ScreenUpdating = False ActiveSheet.Previous.Select Application.ScreenUpdating = True End Sub
Hope it helps.
Windy
-
Re: macro to return user to the previously viewed sheet
(Note: this is air code)
Put this in your ThisWorkbook module:CodePrivate Sub Workbook_Open() Set objLastSheet = Me.ActiveSheet End Sub Private Sub Workbook_SheetDeactivate(ByVal Sh As Object) Set objLastSheet = Sh End Sub
then in a normal module:
CodePublic objLastSheet As Object Sub GotoLastSheet() If Not objLastSheet Is Nothing Then objLastSheet.Activate End Sub
then run GotoLastSheet whenever you want.
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!