Excelで目次を作成する方法
A table of contents is a total game-changer when working with large files – it keeps everything organized and easy to navigate. Unfortunately, unlike Word, Microsoft Excel doesn’t have a simple “Table of Contents” button that adds this handy feature and updates it automatically. No, you’ll have to roll up your sleeves and create a dynamic table of contents yourself. This table will automatically update and contain clickable links, allowing you to add and remove sheets – as well as jump between them – with ease. This guide has all the info you need to create a dynamic table of contents in Excel.
How to Create a Dynamic Table of Contents in Excel
Technically, there are three ways to create a dynamic table of contents (TOC) in Excel. However, only one of them guarantees a fully automated TOC, and that’s Visual Basic for Applications or VBA for short – Microsoft’s native programming language. The other two – traditional formulas and Power Query – will give you a semi-dynamic table of contents in Excel – one that either doesn’t include clickable links or doesn’t update automatically. Since we’re after a fully dynamic Excel table of contents, we’ll use VBA.
If you aren’t particularly VBA-savvy; don’t worry – you just need to follow a few steps. But first – let’s create our table of contents.
Step 1: Click on the “Insert Worksheet” button next to your sheets at the bottom.
Step 2: Name the sheet “Table of Contents.”
Step 3: Drag the sheet to the first position for better navigation.
Step 4: Enter the names of your sheets in Column A of the “Table of Contents” sheet.
And voilà – you’ve got your table of contents. You can play with the aesthetics of this TOC later – now, we need to make it dynamic. To do so, we’ll need the help of the VBA Editor – a built-in Excel tool that lets you write and run custom codes.
Step 1: Press “Alt + F11” to open the VBA Editor.
Step 2: Go to the “Insert” tab at the top.
Step 3: Select “Module” from the dropdown menu.
Step 4: Copy and paste the following VBA code:
Sub CreateTOC()
Dim ws As Worksheet
Dim toc As Worksheet
Dim i As Integer
‘ Check if TOC sheet already exists, delete if it does
On Error Resume Next
Set toc = ThisWorkbook.Sheets(“Table of Contents”)
On Error GoTo 0
If Not toc Is Nothing Then Application.DisplayAlerts = False: toc.Delete: Application.DisplayAlerts = True
‘ Create new TOC sheet
Set toc = ThisWorkbook.Sheets.Add(Before:=ThisWorkbook.Sheets(1))
toc.Name = “Table of Contents”
‘ Set up TOC header
toc.Cells(1, 1).Value = “Table of Contents”
toc.Cells(1, 1).Font.Bold = True
toc.Cells(1, 1).Font.Size = 14
‘ Loop through all sheets and add hyperlinks
i = 2
For Each ws In ThisWorkbook.Sheets
If ws.Name <> “Table of Contents” Then
toc.Hyperlinks.Add Anchor:=toc.Cells(i, 1), _
Address:=””, _
SubAddress:=”‘” & ws.Name & “‘!A1”, _
TextToDisplay:=ws.Name
i = i + 1
End If
Next ws
‘ Adjust column width
toc.Columns(“A”).AutoFit
End Sub
Step 5: Hit “F5” to run the code.
Step 6: Exit the VBA Editor.
You’ll notice your Excel table of contents is now clickable.
To automatically update your table of contents after changes, you just need to repeat Steps 1 to 6. This will add any new sheets to the list or remove the ones you deleted.
以上がExcelで目次を作成する方法の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

Video Face Swap
完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

人気の記事

ホットツール

メモ帳++7.3.1
使いやすく無料のコードエディター

SublimeText3 中国語版
中国語版、とても使いやすい

ゼンドスタジオ 13.0.1
強力な PHP 統合開発環境

ドリームウィーバー CS6
ビジュアル Web 開発ツール

SublimeText3 Mac版
神レベルのコード編集ソフト(SublimeText3)

ホットトピック











Microsoftの最新のPowertoysアップデートでは、Macosのスポットライトを連想させるゲームを変える検索機能を紹介します。 この改善された「コマンドパレット」(以前のPowertoys Run)は、Windows R runコマンドとタスクの機能を上回ります

KB5054979は、Windows 11バージョン24H2のために、2025年3月27日にリリースされた累積セキュリティアップデートです。 .NETフレームワークバージョン3.5および4.8.1をターゲットにし、セキュリティと全体的な安定性を高めます。特に、更新はファイルと直接の問題に対処します

Nanoleafのペグボードデスクドック:スタイリッシュで機能的なデスクオーガナイザー 同じ古い充電セットアップにうんざりしていませんか? Nanoleafの新しいPegboard Desk Dockは、スタイリッシュで機能的な代替品を提供しています。 この多機能デスクアクセサリーは、32のフルカラーRGBを誇っています

DellのUltrasharp 4K Thunderbolt Hubモニター(U2725QE):OLEDに匹敵するLCD 何年もの間、私はOLEDモニターを切望してきました。 しかし、Dellの新しいUltrasharp 4K Thunderbolt Hubモニター(U2725QE)は私の考えを変え、その印象で期待を上回りました

Windows 11 PCをBluetoothスピーカーに変え、お気に入りの音楽をお使いのお気に入りの音楽をお楽しみください!このガイドは、iPhoneまたはAndroidデバイスをコンピューターに簡単に接続してオーディオ再生を示します。 ステップ1:Bluetoothデバイスをペアリングします まず、PA

多くの無料アプリは、有料のカウンターパートに匹敵します。 このリストには、人気のある有料ソフトウェアの優れた無料のWindowsの代替品が紹介されています。 有料のオプションが重要で欠落している機能を提供しない限り、フリーソフトウェアを使用することを固く信じています。 これら

エイリアンウェア27 4K QD-OLED(AW2725Q):見事な高密度ディスプレイ 27インチモニターの899.99ドルの値札は急勾配に見えるかもしれませんが、Alienware AW2725Qの例外的なピクセル密度は、ゲームとすべての両方に変革的な体験を提供します

よりスムーズな体験のために、隠されたWindows機能のロックを解除してください! コンピューティングエクスペリエンスを大幅に向上させることができる驚くほど便利なWindows機能を発見してください。ベテランのWindowsユーザーでさえ、ここでいくつかの新しいトリックを見つけるかもしれません。 ダイナミックロック:自動
