提示:其它语言是由 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。 支持所有语言。 在您的企业或组织中轻松部署。 全功能60天免费试用。
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 · 26 days 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 · 7 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 · 1 years ago
    How can I make the hidden sheet active and hide the home page?