Sub toc()
For i = 1 To Sheets.Count
Cells(Selection(1).Row + i - 1, Selection(1).Column).Value = "=HYPERLINK(""#'" & Worksheets(i).Name & "'!A1"",""" & Worksheets(i).Name & """)"
Next i
End Sub
Sub Table()
'特定のCellではなく選択範囲に罫線を描画する(Selectionというのが選択範囲)
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
'タイトルを塗りつぶし(選択範囲の先頭行のみ)
Range(Selection(1), Selection(1).Offset(0, Selection.Columns.Count - 1)).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent1
.TintAndShade = -0.249977111117893
.PatternTintAndShade = 0
End With
With Selection.Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
'タイトルを描画(選択範囲の先頭行のみ)※これはなくてもいいです
For col = Selection(1).Column To Selection(1).Offset(0, Selection.Columns.Count - 1).Column
Cells(Selection(1).Row, col) = "Col" & col - Selection(1).Column + 1
Next col
End Sub