![]() |
Back button Macro?
How can I create a generic back button for my workbook, so that it goe
to the last view worksheet? Is this even possible -- Message posted from http://www.ExcelForum.com |
Back button Macro?
Fraggs,
Put this code in the ThisWorkbook code module Public prevWs As Worksheet Private Sub Workbook_Open() Set prevWs = ActiveSheet End Sub Private Sub Workbook_SheetDeactivate(ByVal Sh As Object) Set prevWs = Sh End Sub and add this code to a standard code m odule and tie your button to it Sub PrevSheet() ThisWorkbook.prevWs.Activate End Sub -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Fraggs " wrote in message ... How can I create a generic back button for my workbook, so that it goes to the last view worksheet? Is this even possible? --- Message posted from http://www.ExcelForum.com/ |
Back button Macro?
One way:
Code in a regular module: Public OldSheetName As String Public mySheetName As String Sub ReturnToLastSheet() Worksheets(OldSheetName).Activate End Sub Code in the Thisworkbook object: Private Sub Workbook_Open() MySheetName = "Sheet1" 'Change as appropriate End Sub Private Sub Workbook_SheetActivate(ByVal Sh As Object) OldSheetName = mySheetName mySheetName = Sh.Name End Sub Then assign the ReturnToLastSheet macro to a button. HTH Otto "Fraggs " wrote in message ... How can I create a generic back button for my workbook, so that it goes to the last view worksheet? Is this even possible? --- Message posted from http://www.ExcelForum.com/ |
All times are GMT +1. The time now is 07:18 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com