跳到主要内容

如何从工作簿中创建所有工作表名称的列表?

假设您有一个包含多个工作表的工作簿,现在您想列出当前工作簿中的所有工作表名称,是否有任何快速方法可以在Excel中创建这些工作表名称的列表而不用一一键入? 本教程提供有关如何在Excel中列出工作表名称的说明。

使用公式动态获取工作簿中所有工作表名称的列表

从具有有用功能的工作簿中获取所有工作表名称的列表

使用VBA代码从工作簿中获取所有工作表名称的列表


使用公式动态获取工作簿中所有工作表名称的列表

在Excel中,您可以定义范围名称,然后应用公式列出当前工作簿中的所有工作表名称,请执行以下步骤:

1。 点击 公式 > 名称管理员,请参见屏幕截图:

2。 在 名称管理员 对话框,单击 全新 按钮,请参见屏幕截图:

3。 在弹出 新名字 对话框中,在其中指定一个名称 名字 文本框,然后将以下公式复制到 文本框,请参见屏幕截图:

=GET.WORKBOOK(1)&T(NOW())

4。 然后点击 OK > 关闭 要关闭对话框,现在,请转到要列出所有工作表名称的工作表,然后在空白单元格中输入以下公式:

=IFERROR(INDEX(MID(Sheetnames,FIND("]",Sheetnames)+1,255),ROWS($A$2:A2)),"")

备注:在以上公式中, 工作表名称 是您在步骤3中建立的范围名称。

5。 当显示空白单元格时,然后将填充手柄向下拖动到这些单元格,现在,当前工作簿的所有工作表名称都已列出,如下图所示:

6。 如果要为每个工作表创建超链接,请使用以下公式:

=HYPERLINK("#'"&A2&"'!A1","Go To Sheet")

备注:在以上公式中, A2 是包含工作表名称的单元格,并且 A1 是您想要活动单元格所在的单元格。 例如,如果单击超链接文本,它将找到工作表的单元格A1。

7。 现在,当您单击超链接文本时,它将带您到该工作表,请参见下面的演示:

Tips:
  • 1.使用上述公式,将动态列出创建的工作表名称,当您在工作簿中更改工作表名称时,索引工作表名称将自动更新。
  • 2.您应该将文件另存为 Excel启用宏的工作簿 格式,如果您希望公式在文件关闭并重新打开后能正常工作。

从具有有用功能的工作簿中获取所有工作表名称的列表

随着 创建工作表名称列表 第三方加载项的实用程序 Kutools for Excel,您只需单击即可创建工作表名称列表,并使用超链接链接到每个工作表。

请注意:申请这个 创建工作表名称列表,首先,您应该下载 Kutools for Excel,然后快速轻松地应用该功能。

安装后 Kutools for Excel,请这样做:

1. 点击 Kutools 加 > 工作表 > 创建工作表名称列表,请参见屏幕截图:

2。 在 创建工作表名称列表 对话框中,请指定以下设置:

(1.)选择 工作表索引样式 您可以使用超链接或宏按钮创建工作表名称。

(2.)输入图纸索引的工作表名称。

(3.)指定工作表索引的位置。

(4.)指定要在新工作表中使用多少列来显示工作表名称。

3. 完成设置后,然后单击 OK。 在当前工作簿的新工作表中,所有工作表名称均已列出,并带有链接。 看截图:

带超链接的工作表名称 带宏按钮的工作表名称
Tips::要使用此功能,您应该安装 Kutools for Excel 首先,请 点击下载并享受 30 天免费试用 现在。

使用VBA代码从工作簿中获取所有工作表名称的列表

1。 按住 ALT + F11 键,然后打开 Microsoft Visual Basic应用程序 窗口。

2。 点击 插页 > 模块,然后将以下宏粘贴到 模块 窗口。

VBA:在新工作表中列出所有带有超链接的工作表名称:

Sub CreateIndex()
'updateby Extendoffice
    Dim xAlerts As Boolean
    Dim I  As Long
    Dim xShtIndex As Worksheet
    Dim xSht As Variant
    xAlerts = Application.DisplayAlerts
    Application.DisplayAlerts = False
    On Error Resume Next
    Sheets("Index").Delete
    On Error GoTo 0
    Set xShtIndex = Sheets.Add(Sheets(1))
    xShtIndex.Name = "Index"
    I = 1
    Cells(1, 1).Value = "INDEX"
    For Each xSht In ThisWorkbook.Sheets
        If xSht.Name <> "Index" Then
            I = I + 1
            xShtIndex.Hyperlinks.Add Cells(I, 1), "", "'" & xSht.Name & "'!A1", , xSht.Name
        End If
    Next
    Application.DisplayAlerts = xAlerts
End Sub

3。 按 F5 键运行该宏。 现在活动工作簿中的所有工作表名称都已列出到名为“索引”的新工作表中,并且工作表名称也链接到每个工作表,请参见屏幕截图:

Comments (19)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
First, thanks to the author. And adding the Czech version.

tp 3. =O.KNIZE(1)&T(NYNÍ())
tp 4. =IFERROR(INDEX(ČÁST(nazvylistu;NAJÍT("]";nazvylistu)+1;255);ŘÁDKY($A$2:A4));"")
This comment was minimized by the moderator on the site
Hello,

je viens de tester la méthode via macros (dynamique avec formules) et ça marche au poil donc je tiens vraiment à remercier l'auteur de cet article parce que ça va vraiment m'aider dans mon travail ! Juste, je me permet de corriger les formules pour la version française. Et alors je ne sais pas si c'est parce que je suis sous la version 2019 mais Excel rouspète quand il n'y a pas d'argument en 3ème position de la fonction STXT ("MID" en version anglaise) donc obligé d'en rajouter un. Donc voilà ce que ça donne :

=LIRE.CLASSEUR(1)&T(MAINTENANT())

=SIERREUR(INDEX(STXT(nomsFeuilles;TROUVE("]";nomsFeuilles)+1,255;20);LIGNES($A$2:A2));"")

Bon travail à tous ! ;-)
This comment was minimized by the moderator on the site
Hello, Gizmil
Thank you for your comment, there are some functions are only available for English in Excel.
Your formula may help others.
Thanks again!
This comment was minimized by the moderator on the site
I close and open my document and all values in my sheet names column are all gone and blank but still the formula is there. I tried entering the same formula but it doesn't show the value anymore
This comment was minimized by the moderator on the site
Hello, Anne,
Sorrry for replying late, after creating the range names and formulas, you should save the workbook as Excel Macro-Enabled Workbook format, so next time, when you open the Excel file,the formulas can work well.
Please try, hope it can help you!
This comment was minimized by the moderator on the site
I tried this one and it works. But when I close and open the file again all the values in my sheet names are blank and gone but the formula is still there. I tried enteing the same formula again but it doesn't show the value anymore
This comment was minimized by the moderator on the site
BRILLIANT!! Thank you so much! 😊
This comment was minimized by the moderator on the site
Causes problems when document protection is enabled by email or corporate policy
This comment was minimized by the moderator on the site
Thanks so much, this worked great.
This comment was minimized by the moderator on the site
Works great!! Thank you!!!!
This comment was minimized by the moderator on the site
sooooo helpful, works as expected!!!!! Thanks
This comment was minimized by the moderator on the site
THANK YOU SO MUCH! I freaking love your website. In a matter of minutes I've had a ton of time saved with two sections of this site including this one. Love it!
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations