How to double click a cell to open a specified worksheet in Excel?
Do you want to quickly navigate to a specified worksheet in an Excel workbook? This article will provide a VBA method to open a specified worksheet by double-clicking a certain cell in Excel.
Please do as follows to open a specified worksheet by double-clicking a cell in Excel.
1. Right-click the sheet tab which contains the cell you want to open worksheet by clicking on it. And then click View Code from the context menu. See screenshot:
2. In the opening Microsoft Visual Basic for Applications window, please copy the following VBA code into the Code window.
VBA code: double click cell to open a specified worksheet in Excel
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) 'Updated by Extendoffice 20180822 Dim xArray, xAValue As Variant Dim xFNum As Long Dim xStr, xStrRg, xStrSheetName As String xRgArray = Array("A1;Sheet2", "A12;Sheet3", "A4;Sheet4", "A100;Sheet5") On Error Resume Next For xFNum = LBound(xRgArray) To UBound(xRgArray) xStr = "" xStr = xRgArray(xFNum) xAValue = "" xAValue = Split(xStr, ";") xStrRg = "" xStrRg = xAValue(0) xStrSheetName = "" xStrSheetName = xAValue(1) If Not Intersect(Target, Range(xStrRg)) Is Nothing Then Sheets(xStrSheetName).Activate End If Next End Sub
Note: In the VBA code, "A1;Sheet2", "A12;Sheet3", "A4;Sheet4", "A100;Sheet5" mean that doube click cell A1 will open Sheet2, double click A2 will open Sheet3..., please change them based on your needs.
3. Press the Alt + Q keys together to close the Microsoft Visual Basic for Applications window.
From now on, when double clicking cell A1 in current worksheet, the specified worksheet will be activated immediately.
- How to click or double click cell to open a specified user form in Excel?
- How to add check mark in a cell with double clicking in Excel?
- How to auto add/enter current date/time in a cell with double clicking in Excel?
- How to double click a cell and add 1 to that cell value in Excel?
- How to pop up a calendar when clicking a specific cell in Excel?