Hello,
I found this usefull macro and mz VBA Editor gives me error: Expected variable or procedure, not module.
and Highlight Sheets("Index").Delete
or here: Sheets.Add before:=Sheets(1)
Where is the problem ? Thank you
I found this usefull macro and mz VBA Editor gives me error: Expected variable or procedure, not module.
and Highlight Sheets("Index").Delete
Code:
Sub CreateIndex()
'updateby Extendoffice 20150914
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
or here: Sheets.Add before:=Sheets(1)
Code:
Sub CreateIndex2()
Dim sheetnum As Integer
Sheets.Add before:=Sheets(1)
For sheetnum = 2 To Worksheets.Count
ActiveSheet.Hyperlinks.Add _
Anchor:=Cells(sheetnum - 1, 1), _
Address:="", _
SubAddress:="'" & Worksheets(sheetnum).name & "'!A1", _
TextToDisplay:=Worksheets(sheetnum).name
Next sheetnum
ActiveWindow.DisplayGridlines = False
End Sub