ich bitte um Hilfe bei folgendem Code:
Ich lasse mir spalten sortieren.
Wenn eine ausfgeführte z.B. Spa = Application.Match("Nr.", Rows(1), 0)
aber nicht vorhanden ist bekomme ich Laufzeitfehler 13 (Typen unverträglich)
Ich möchte das der Code in MsgBox auflistet welche er nicht gefunden hat und dann "End Sub " ohne "Error, Debugger"etc
Könnt ihr das mit einbauen!?
Vielen Dank schon einmal im Voraus.
MfG
Thorben
Sub rearangeColumnsStart()
Dim Spa As Long
Dim x As Range
With Application
.ScreenUpdating = False
.DisplayAlerts = False
.EnableEvents = False
End With
With Tabelle1
Spa = Application.Match("Nr.", Rows(1), 0)
Columns(Spa).Cut _
Destination:=Cells(1, Cells(1, Columns.Count).End(xlToLeft).Column + 1)
Columns(Spa).Delete
Spa = Application.Match("Herkunft", Rows(1), 0)
Columns(Spa).Cut _
Destination:=Cells(1, Cells(1, Columns.Count).End(xlToLeft).Column + 1)
Columns(Spa).Delete
Spa = Application.Match("Beschreibung", Rows(1), 0)
Columns(Spa).Cut _
Destination:=Cells(1, Cells(1, Columns.Count).End(xlToLeft).Column + 1)
Columns(Spa).Delete
'usw.
Set x = Cells.Find("Nr.", After:=Cells(Rows.Count, Columns.Count), searchorder:=xlByColumns, _
searchdirection:=xlPrevious)
If Not x Is Nothing Then If x.Column > 1 Then Range(Cells(1, 1), Cells(1, x.Column - 1)). _
EntireColumn.Delete
End With
End Sub