AW: Reihenfolge Sheets in Array
15.08.2018 20:44:50
Sepp
Hallo Frank,
man könnte die Blätter in eine neue Datei kopieren, sortieren, exportieren und die Datei wieder löschen.
Sub test()
Dim varSheets As Variant, lngIndex As Long
On Error GoTo ErrorHandler
With Application
.ScreenUpdating = False
.EnableEvents = False
.AskToUpdateLinks = False
.DisplayAlerts = False
.Calculation = xlCalculationManual
End With
'Tabellenblätter in der gewünschten Reihenfolge!
varSheets = Array("Tabelle4", "Tabelle2", "Tabelle1")
Sheets(varSheets).Copy
With ActiveWorkbook
For lngIndex = Ubound(varSheets) To 0 Step -1
.Sheets(varSheets(lngIndex)).Move Before:=.Sheets(1)
Next
.ExportAsFixedFormat xlTypePDF, "D:\Forum\test.pdf"
.Close False
End With
ErrorHandler:
If Err.Number <> 0 Then
MsgBox "Fehler in Modul3" & vbLf & vbLf & "Prozedur:" & vbTab & "test" & vbLf & _
"Nummer:" & vbTab & Err.Number & vbLf & "Meldung:" & vbTab & Err.Description & vbLf & _
IIf(Erl, "Zeile:" & vbTab & Erl, ""), vbExclamation, "Fehler!"
Err.Clear
End If
With Application
.ScreenUpdating = True
.EnableEvents = True
.AskToUpdateLinks = True
.DisplayAlerts = True
.Calculation = xlCalculationAutomatic
End With
End Sub
VBA/HTML-CodeConverter, AddIn für Office 2002-2016 - in VBA geschrieben von Lukas Mosimann. Projektbetreuung:RMH Software & Media
Code erstellt und getestet in Office 16 - mit VBAHTML 12.6.0