跳到主要內容

如何從工作簿中創建所有工作表名稱的列表?

假設您有一個包含多個工作表的工作簿,現在您想列出當前工作簿中的所有工作表名稱,是否有任何快速方法可以在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。 現在,當您單擊超鏈接文本時,它將帶您到該工作表,請參見下面的演示:

保養竅門:
  • 1.使用上述公式,將動態列出創建的工作表名稱,當您在工作簿中更改工作表名稱時,索引工作表名稱將自動更新。
  • 2.您應該將文件另存為 Excel啟用宏的工作簿 格式,如果您希望公式在文件關閉並重新打開後能正常工作。

從具有有用功能的工作簿中獲取所有工作表名稱的列表

隨著 創建工作表名稱列表 第三方加載項的實用程序 Excel的Kutools,您只需單擊即可創建工作表名稱的列表,並使用超鏈接鏈接到每個工作表。

注意:要應用此 創建工作表名稱列表,首先,您應該下載 Excel的Kutools,然後快速輕鬆地應用該功能。

安裝後 Excel的Kutools,請這樣做:

1. 點擊 Kutools 加 > 下載學習單 > 創建工作表名稱列表,請參見屏幕截圖:

2。 在 創建工作表名稱列表 對話框中,請指定以下設置:

(1.)選擇 工作表索引樣式 您可以使用超鏈接或宏按鈕創建工作表名稱。

(2.)輸入圖紙索引的工作表名稱。

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

(4.)指定要在新工作表中使用多少列來顯示工作表名稱。

3. 完成設置後,然後單擊 OK。 在當前工作簿的新工作表中,所有工作表名稱均已列出,並帶有鏈接。 看截圖:

帶超鏈接的工作表名稱 帶宏按鈕的工作表名稱
尖端:要使用此功能,您應該安裝 Excel的Kutools 首先,請 點擊下載並獲得 30 天免費試用

使用VBA代碼從工作簿中獲取所有工作表名稱的列表

1。 按住 ALT + F11 鍵,然後打開 Microsoft Visual Basic for Applications 窗口。

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