Ich habe ein Problem mit meinem Makro.
Das Ergebnis sollte so sein:
In einer Spalte im Blatt (hier die Spalte D3 in Blatt "Navigation") soll zunächst nur der Inhalt (nicht die Formatierung) gelöscht werden.
Anschließend werden alle Blätter mit ihrer Bezeichnung ausgelesen und im Blatt "Navigation" als Inhaltsverzeichnis mit Hyperlinks eingefügt.
Ich habs so probiert:
Sub Navigation()
'updateby Extendoffice 20180413
Dim xAlerts As Boolean
Dim I As Long
Dim Navigation As Worksheet
Dim xSht As Variant
xAlerts = Application.DisplayAlerts
Application.DisplayAlerts = False
On Error Resume Next
On Error GoTo 0
Range("d13:d50").Select
Selection.ClearContents
I = 12
'Cells(10, 3).Value = "Inhaltsverzeichnis"
For Each xSht In ThisWorkbook.Sheets
If xSht.Name > "Navigation" Then
I = I + 1
Navigation.Hyperlinks.Add Cells(I, 13), "", "'" & xSht.Name & "'!a1", , xSht.Name
End If
Next
Application.DisplayAlerts = xAlerts
End Sub
Zunächst wird alles wie gewünscht gelöscht.
Beim neu befüllen bekomme ich in der Zeile:
Navigation.Hyperlinks.Add Cells(I, 13), "", "'" & xSht.Name & "'!a1", , xSht.Name
die Fehlermeldung:
"Objektvariable oder With-Blockvariable nicht festgelegt"
Kann mir bitte jemand weiterhelfen?
Besten Dank
Bernie