ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Moving to Previous Worksheet (https://www.excelbanter.com/excel-worksheet-functions/112848-moving-previous-worksheet.html)

Zootie

Moving to Previous Worksheet
 
Is there a quick way to open the last worksheet you had open prior to the one
you are currently viewing, and toggle between the two sheets? I am looking
for something like the alt+tab command for windows.


PCLIVE

Moving to Previous Worksheet
 
I'm assuming you do mean Worksheet, as stated, and not Workbook.

Anyway, you can use some code to do this. I've previously done something
like this with the following:

First, create a sheet named "Data". This sheet can be hidden if you'd like.
Next, press Alt+F11 to bring up the VB editor.
Double-click on "ThisWorkbook".
Paste the following code:

Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
Sheets("Data").Range("A2").Value = Sheets("Data").Range("A1").Value
Sheets("Data").Range("A1").Value = ActiveSheet.Name
End Sub

Next, right-click "ThisWorkbook" again and goto "Insert" and then select
"Module".
Paste the following code:

Sub ActivateLastSheet()
Sheets(Sheets("Data").Range("A2").Value).Activate
End Sub

Close the VB Editor window.
From your Excel window, click Tools-Macro-Macros.
Select ActivateLastSheet and then click Options.
In this section you can assign a short-cut key to easily access the code
that activates the previous sheet you were on.


Hope this is helpful.
Paul

"Zootie" wrote in message
...
Is there a quick way to open the last worksheet you had open prior to the
one
you are currently viewing, and toggle between the two sheets? I am
looking
for something like the alt+tab command for windows.





All times are GMT +1. The time now is 08:49 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com