※上記の広告は60日以上更新のないWIKIに表示されています。更新することで広告が下部へ移動します。


2009-10-25 23:22:16 (Sun)



Public Sub 目次作成()
Const TITLE = "目次"
Dim i As Integer
For i = 1 To Worksheets.Count
If Sheets(i).Name = TITLE Then
Application.DisplayAlerts = False
Sheets(TITLE).Delete
Application.DisplayAlerts = True
Exit For
End If
Next i
Sheets.Add.Name = TITLE
Sheets(TITLE).Select
Sheets(TITLE).Move Before:=Sheets(1)

Dim row As Integer
row = 2
Sheets(TITLE).Cells(row, 1) = TITLE
Sheets(TITLE).Cells(row, 1).HorizontalAlignment = xlHAlignCenter
row = row + 3
For Each s In Worksheets
If s.Name <> TITLE Then
Sheets(TITLE).Cells(row, 1) = s.Name
Sheets(TITLE).Hyperlinks.Add _
Anchor:=Sheets(TITLE).Cells(row, 1), _
Address:="", _
SubAddress:=s.Name + "!A1"
row = row + 1
End If
Next
Sheets(TITLE).Columns(1).ColumnWidth = 64
End Sub