提示:其他語言是Google翻譯的。 你可以訪問 English 版本。
登入
x
or
x
x
註冊
x

or

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

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

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


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

Kutools for Excel's 創建圖紙名稱列表 實用程序,您可以使用超鏈接或宏按鈕快速列出新工作表中的所有工作表名稱,然後您可以根據需要在它們之間導航。

Kutools for Excel:比200方便的Excel加載項,可以在60天免費試用。 下載並免費試用現在!


通過使用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。 然後保存並關閉此代碼窗口,然後單擊 設計模式 要關閉設計模式,現在,從組合框中選擇一個圖紙名稱時,它將立即轉到該圖紙,請參閱截圖:


Kutools for Excel解決了您的大多數問題,並使您的生產率提高了80%

  • 重用: 快速插入 複雜的公式,圖表 以及你以前用過的任何東西; 加密單元格 密碼; 創建郵件列表 並發送電子郵件...
  • 超級方程式酒吧 (輕鬆編輯多行文字和公式); 閱讀佈局 (輕鬆讀取和編輯大量單元格); 粘貼到過濾範圍...
  • 合併單元格/行/列 不丟失數據; 分裂細胞含量; 組合重複的行/列...防止重複的細胞; 比較範圍...
  • 選擇複製或唯一 行; 選擇空行 (所有細胞都是空的); 超級查找和模糊查找 在許多工作簿中; 隨機選擇......
  • 精確複製 多個單元格而不更改公式參考; 自動創建參考 多張表; 插入項目符號,複選框等等......
  • 提取文本,添加文本,按位置刪除, 刪除空間; 創建和打印分頁小計; 在單元格內容和註釋之間轉換...
  • 超級過濾器 (將過濾方案保存並應用到其他工作表); 高級排序 按月/週/日,頻率等; 特殊過濾器 用粗體,斜體......
  • 結合工作簿和工作表; 根據鍵列合併表; 將數據拆分為多個表格; 批量轉換xls,xlsx和PDF...
  • 超過300強大的功能。 支持Office / Excel 2007-2019和365。 支持所有語言。 在您的企業或組織中輕鬆部署。 全功能30天免費試用。
kte tab 201905

Office選項卡為Office提供選項卡式界面,使您的工作更輕鬆

  • 在Word,Excel,PowerPoint中啟用選項卡式編輯和閱讀,Publisher,Access,Visio和Project。
  • 在同一窗口的新選項卡中打開並創建多個文檔,而不是在新窗口中。
  • 通過50%提高您的工作效率,每天為您減少數百次鼠標點擊!
官方底部
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Ilovemacro · 3 months ago
    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
  • To post as a guest, your comment is unpublished.
    roseanne · 10 months ago
    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
  • To post as a guest, your comment is unpublished.
    M · 1 years ago
    How do you change this to only show/select visible worksheets?
    • To post as a guest, your comment is unpublished.
      skyyang · 1 years ago
      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!
      • To post as a guest, your comment is unpublished.
        M · 1 years ago
        It worked! Thank you! Do you know if this code will cause problems if sheets are renamed or will it update the list automatically?
        • To post as a guest, your comment is unpublished.
          skyyang · 1 years ago
          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.
  • To post as a guest, your comment is unpublished.
    Emmanuel · 1 years ago
    How can I add only specific sheets? and not all the sheet in the workbook
    • To post as a guest, your comment is unpublished.
      Christian · 1 years ago
      Did you have any joy finding code to show only certain sheets in the dropdown box?
  • To post as a guest, your comment is unpublished.
    Ghaz · 2 years ago
    How can I make the hidden sheet active and hide the home page?