How to Create Shortcut to Go Back to Previous Worksheet in Excel

Usually we create multiple worksheets in excel and we can switch between these worksheets to do different operations. But if we want to quickly get back from current worksheet to the previous operating worksheet , how can we do? Dragging the scroll bar back to the previous worksheet is hard to find the proper worksheet due to sometimes we forget the name of the last worksheet, so it’s good to have a shortcut to go back to the previous worksheet. This article will introduce you how to create a shortcut key to go back to previous worksheet by VBA.

Create Shortcut Key to Go Back to Previous Worksheet by VBA


Step 1: Click Developer tab->Visual Basic or Alt+F11 to load Microsoft Visual Basic for Applications window.

Create Shortcut to Go Back to Previous Worksheet 1

Step 2: Double click on ThisWorkbook under VBAProject->Microsoft Excel Objects in the left bar.

Step 3: Enter below code into the window.

Private Sub Workbook_SheetDeactivate(ByVal Psh As Object)
    PreviousSheet = Psh.Name
End Sub

Create Shortcut to Go Back to Previous Worksheet 2

Step 4: On current workbook, click Insert->Module to insert a module. Then Module1 is created.

Create Shortcut to Go Back to Previous Worksheet 3

Step 5: Click Module1, then enter below code.

Create Shortcut to Go Back to Previous Worksheet 4

Public PreviousSheet As String
    Sub Select_PreviousSheet()
    Application.Sheets(PreviousSheet).Select
End Sub

Create Shortcut to Go Back to Previous Worksheet 5

Step 6: Return to worksheet window, click Developer->Macros, in the opening Macro window, verify that Select_PreviousSheet is already listed.

Create Shortcut to Go Back to Previous Worksheet 6

x
How to Select Every Other Row in Excel

Step 7: Highlight ‘Select_PreviousSheet’, then click Options button. In Macro Options window, set Crtl + p as the shortcut key, enter the description as well. See screenshot below. Then click OK.

Create Shortcut to Go Back to Previous Worksheet 7

Step 8: Now you can switch between worksheets and check if the shortcut key is available. The shortcut key works well, it can help us return to previous worksheet quickly.

 

 

Related Posts

VBA Macro For VLOOKUP From Another Sheet
vba macro for vlookup from another sheet1

In the previous post, you should know that how to fix or remove the #N/A error when using VLOOKUP formula to lookup value from another sheet. And this post will show you how to use VBA code to vlookup data ...

How To Insert Comments in Protected Worksheet in Excel
insert commetns in protected workshee3

This post will show you how to allow comments in a protected worksheet in Excel. You can easily to insert comments into cells in a normal worksheet in Excel, but if want to insert a comment in a worksheet that ...

How To Convert Text to Upper Cases(Using VBA) in Excel
convert text to upper cases1

This post will show you how to switch from lower case to upper case in Excel. and I am going to show you two different ways of converting text to upper cases using formula or VBA macro in Excel 2013,Excel ...

How To Hide Every Other Row in Excel (Using VBA)
hide every other row1

This post will show you how to hide alternate rows or columns in Excel or how to hide every third, fourth, fifth row or column in Excel. If you want to hide every other row in your current worksheet, how ...

How to Disable the Save As Prompt in Excel
disable save as prompt1

This post will show you how to use a VBA Macro to save an Excel file and overwrite any existing file without a prompt so that you are going to get the little window that says file already exists do ...

How to Count Cells that Contain even or odd numbers in Excel
count cells that contain even numbers5

This post will guide you how to count the number of cells that contain odd or even numbers within a range of cells using a formula in Excel 2013/2016.How do I count cells that contain odd numbers through the use ...

How to Count Cells that Contain negative Numbers in Excel

This post will guide you how to count the number of cells that contain negative numbers within a range of cells using a formula in Excel 2013/2016.You can count the number of negative numbers in your data using easy functions ...

How to Count Cells Are Not Blank or Empty in Excel
count non blank nonempty cells5

This post will guide you how to count cells that are not blank or empty in a given range cells using a formula in Excel 2013/2016.How do I count the number of cells that are not blank in a particular ...

How to Count Cells Less Than a Specific Value in Excel
count cells lessr than5

This post will guide you how to count the number of cells less than a particular numeric value in a given range cells using a formula in Excel 2013/2016. How do I count cells that are less than a specific ...

How to Count Cells Greater Than a Specific Value in Excel
count cells greater than 5

This post will guide you how to count the number of cells greater than a particular numeric value in a given range cells using a formula in Excel 2013/2016. How do I count cells that are greater than a specific ...

Sidebar