Forum

Notifications
Clear all

Moving from current worksheet to last active worksheet?

4 Posts
3 Users
0 Reactions
185 Views
(@alanr)
Posts: 79
Estimable Member
Topic starter
 

Hi there,

Does anyone know of a keyboard short cut or maybe a bit of VBA that allows you to move between the worksheet you are on and the last worksheet you were on within a workbook?  I have a couple of workbooks with a lot of tabs and this would be a really handy feature to have. 

Alan

 
Posted : 31/01/2022 12:15 pm
Anders Sehlstedt
(@sehlsan)
Posts: 970
Prominent Member
 

Hello Alan,

All I know of is the standard shortcuts to use Ctrl + PgUp/PgDown to move up/down the range of sheets. If there are many sheets I right click the navigation arrows on bottom left to get a pop-up window of all the sheets.

Br,
Anders

 
Posted : 01/02/2022 3:21 am
(@alanr)
Posts: 79
Estimable Member
Topic starter
 

Thanks for the reply Anders - there does not seem to be a feature for this yet - I do see some VBA based solutions on the web - I will give them a go.

 

Alan

 
Posted : 03/02/2022 11:52 pm
(@questvba)
Posts: 125
Estimable Member
 

Hi Alan,

Here is a VBA solution.

1. In ThisWorkbook, you paste the following two codes.

The first code allows you to initialize the shortcut keys with the main macro 'Select_Last_Sheet'.

For the example, I have chosen the following combination : CTRL + ALT + J

Private Sub Workbook_Open()

LastSheet = ActiveSheet.Name

Application.OnKey "^%j", "Select_Last"

End Sub

The second code retrieves the name of the last sheet

Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)

LastSheet = Sh.Name

End Sub

2. Then, you create a module in which you put this code. It allows you to teleport to the desired tab.

Public LastSheet As String

Sub Select_Last_Sheet()

Application.Sheets(LastSheet).Select

End Sub

 

Info : the table below gives an overview of the syntax to be used. There are many others.

Key Key code
Capital +
Control ^
Alt %
Suppr {DELETE}
Backspace {BACKSPACE}

BR,

Lionel

 
Posted : 04/02/2022 3:41 am
Share: