View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Return To Last Active Sheet

Try this


Sub ReturnToPreviousWorksheet()
Sheets(ThisWorkbook.Previous).Select
End Sub


and


Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
Previous = Sh.Name
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Carl" wrote in message
...
I am using the following two macros to return the user to the last active
sheet after visiting another sheet (when they leave the first sheet the
first
macro runs; when wanting to return, they run the second). The problem is
that
it forces them to go momentarily to the sheet "Summary" first. Is there a
better way to do this? I searched all the other strings and could not find
something that would work. Hiding the "Summary" sheet did not work either.
Thanks in adavance,
Sub FreezePreviousWorksheet()
Previous = ActiveSheet.Name
Application.Goto Sheets("Summary").Range("A1")
ActiveCell = Previous
End Sub
Sub ReturnToPreviousWorksheet()
Previous = Sheets("Summary").Range("A1")
Sheets(Previous).Select
End Sub