PDA

View Full Version : How to return to the previously viewed worksheet?



blade402
11-23-2013, 03:20 PM
I want to be able to return to the worksheet I was looking at when I activate coding that takes me away from the currently viewed worksheet. I tried this, but it is now working. Anyone know how to fix this?

Code:
'in ThisWorkbook
Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
Set LstSht = Sh End Sub
'in Standard Module
Public LstSht As Worksheet

Sub GoToLast() LstSht.Activate

End Sub

EirikDaude
11-23-2013, 04:31 PM
If you want to use the same variable in a different module, I think you'll have to set it as public.

rollis13
11-23-2013, 04:31 PM
Cross-post: http://www.mrexcel.com/forum/excel-questions/741299-how-return-previously-viewed-worksheet.html