跳到主要內容

如何通過使用Excel中的下拉列表在工作表之間導航?

假設您有一個包含多個工作表的工作簿,現在,您需要創建一個下拉列表或組合框,其中列出了所有工作表名稱,當您從下拉列表中選擇一個工作表名稱時,它將立即跳至該工作表。 本文,我將介紹如何通過使用Excel中的下拉列表在工作表之間導航。

通過使用Excel中的下拉列表在工作表之間導航


通過使用Excel中的下拉列表在工作表之間導航

要使用下拉列表跳至每個選定的工作表,請執行以下步驟:

1。 點擊 開發者 > 插入 > 組合框(ActiveX控件),請參見屏幕截圖:

2。 然後拖動鼠標以繪製一個組合框,然後右鍵單擊它,選擇 查看代碼 從上下文菜單中,查看屏幕截圖:

3。 在開 Microsoft Visual Basic for Applications 窗口中,複製並粘貼以下代碼以替換原始代碼,請參見屏幕截圖:

VBA代碼:使用下拉列表在工作表之間導航

Private Sub ComboBox1_Change()
'Updateby Extendoffice
    If ComboBox1.ListIndex > -1 Then Sheets(ComboBox1.Text).Select
End Sub
Private Sub ComboBox1_DropButtonClick()
    Dim xSheet As Worksheet
    On Error Resume Next
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    If ComboBox1.ListCount <> ThisWorkbook.Sheets.Count Then
        ComboBox1.Clear
        For Each xSheet In ThisWorkbook.Sheets
            ComboBox1.AddItem xSheet.Name
        Next xSheet
    End If
    Application.EnableEvents = True
    Application.ScreenUpdating = True
End Sub
Private Sub ComboBox1_GotFocus()
    If ComboBox1.ListCount <> 0 Then ComboBox1.DropDown
End Sub

4。 然後保存並關閉此代碼窗口,然後單擊 設計模式 要關閉設計模式,現在,從組合框中選擇一個工作表名稱時,它將立即轉到該工作表,請參見屏幕截圖:


使用超鏈接或按鈕在工作表之間導航:

這款獨特的敏感免洗唇膜採用 Moisture WrapTM 技術和 Berry Mix ComplexTM 成分, Excel的Kutools's 創建工作表名稱列表 實用程序,您可以使用超鏈接或宏按鈕在新工作表中快速列出所有工作表名稱,然後可以根據需要在它們之間進行導航。

Excel的Kutools:具有300多個方便的Excel加載項,可以在30天內免費試用,沒有任何限制。 立即下載並免費試用!

最佳辦公生產力工具

🤖 Kutools 人工智慧助手:基於以下內容徹底改變數據分析: 智慧執行   |  生成代碼  |  建立自訂公式  |  分析數據並產生圖表  |  呼叫 Kutools 函數...
熱門特色: 尋找、突出顯示或識別重複項   |  刪除空白行   |  合併列或儲存格而不遺失數據   |   沒有公式的回合 ...
超級查詢: 多條件VLookup    多值VLookup  |   跨多個工作表的 VLookup   |   模糊查詢 ....
高級下拉列表: 快速建立下拉列表   |  依賴下拉列表   |  多選下拉列表 ....
欄目經理: 新增特定數量的列  |  移動列  |  切換隱藏列的可見性狀態  |  比較範圍和列 ...
特色功能: 網格焦點   |  設計圖   |   大方程式酒吧    工作簿和工作表管理器   |  資源庫 (自動文字)   |  日期選擇器   |  合併工作表   |  加密/解密單元格    按清單發送電子郵件   |  超級濾鏡   |   特殊過濾器 (過濾粗體/斜體/刪除線...)...
前 15 個工具集12 文本 工具 (添加文本, 刪除字符,...)   |   50+ 圖表 類型 (甘特圖,...)   |   40+ 實用 公式 (根據生日計算年齡,...)   |   19 插入 工具 (插入二維碼, 從路徑插入圖片,...)   |   12 轉化 工具 (數字到單詞, 貨幣兌換,...)   |   7 合併與拆分 工具 (高級合併行, 分裂細胞,...)   |   ... 和更多

使用 Kutools for Excel 增強您的 Excel 技能,體驗前所未有的效率。 Kutools for Excel 提供了 300 多種進階功能來提高生產力並節省時間。  點擊此處獲取您最需要的功能...

產品描述


Office選項卡為Office帶來了選項卡式界面,使您的工作更加輕鬆

  • 在Word,Excel,PowerPoint中啟用選項卡式編輯和閱讀,發布者,Access,Visio和Project。
  • 在同一窗口的新選項卡中而不是在新窗口中打開並創建多個文檔。
  • 將您的工作效率提高 50%,每天為您減少數百次鼠標點擊!
Comments (12)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
The drop down list will not open hidden sheets, is it able to open hidden sheets?
This comment was minimized by the moderator on the site
hi, is it possible to combine various option from different dropdowns and open sheets accordingly.

eg: if Option1 from dropdown1 is selected and Option2 from dropdown2 is selected then only the Sheet2 will open
This comment was minimized by the moderator on the site
hi there,
Thank you very much for the code which create a dynamic combo box to navigate the sheets. Unfortunately I got an error. After navigating few sheets, the file automatically close. It doesn't even show any error message. I couldn't figure out the reason. I appreciate the help
Thanks
This comment was minimized by the moderator on the site
same error too, Did you figure it out?
This comment was minimized by the moderator on the site
thanks for your code. It works for switching different sheet based on dropdown list.
But I have several questions.
1. after I process the related sheet, and want to go back to main menu(with sheet dropdown list), how could I do without using mouse?
2. when I open the file, I would like the main menu(with dropdown list) as default . So I could start from this menu
thanks
rose
This comment was minimized by the moderator on the site
How do you change this to only show/select visible worksheets?
This comment was minimized by the moderator on the site
Hi,
To ignore the hidden sheets from the drop down list, and only keep the visible worksheets, the following VBA code may help you:

Private Sub ComboBox1_Change()
'Updateby Extendoffice
If ComboBox1.ListIndex > -1 Then Sheets(ComboBox1.Text).Select
End Sub
Private Sub ComboBox1_DropButtonClick()
Dim xSheet As Worksheet
On Error Resume Next
Application.ScreenUpdating = False
Application.EnableEvents = False
If ComboBox1.ListCount <> ThisWorkbook.Sheets.Count Then
ComboBox1.Clear
For Each xSheet In ThisWorkbook.Sheets
If xSheet.Visible Then
ComboBox1.AddItem xSheet.Name
End If
Next xSheet
End If
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
Private Sub ComboBox1_GotFocus()
If ComboBox1.ListCount <> 0 Then ComboBox1.DropDown
End Sub

Please try it, hope it can help you!
This comment was minimized by the moderator on the site
It worked! Thank you! Do you know if this code will cause problems if sheets are renamed or will it update the list automatically?
This comment was minimized by the moderator on the site
Hello,
The above code works well when renaming the sheet name and the items in the drop down list will be updated automatically.
You can try it.
This comment was minimized by the moderator on the site
How can I add only specific sheets? and not all the sheet in the workbook
This comment was minimized by the moderator on the site
Did you have any joy finding code to show only certain sheets in the dropdown box?
This comment was minimized by the moderator on the site
How can I make the hidden sheet active and hide the home page?
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations