VBA Code vereinfachen
02.09.2021 00:39:55
Marko
mit folgendem Code kann ich ein PDF erzeugen und dieses speichern. Die Ausführung dauert jedoch extrem lange ca.5 Minuten. Wie kann ich dieses Makro beschleunigen?
Vielen Dank für Eure Hilfe. Gruß Marko
Private Sub CommandButton2_Click()
CommandButton2.Caption = "PDF erzeugen"
With Application
.ScreenUpdating = False
.EnableEvents = False
.Calculation = xlCalculationManual
End With
Dim strFilename As String
strFilename = Environ("USERPROFILE") & "\Documents\" & "\KoBo\" & Sheets("Tabelle3").Range("L20").Text & ".pdf"
If Dir(strFilename) = "" Then
Sheets("Tabelle1").Calculate
Sheets("Tabelle3").Calculate
Sheets("Tabelle3").Range("K65:K381").AutoFilter Field:=1, Criteria1:="x", visibledropdown:=False
Sheets("Tabelle3").ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=strFilename, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Else
MsgBox "Diese PDF-Datei existiert bereits", vbOKOnly + vbInformation, "Hinweis"
End If
Sheets("Tabelle3").Range("M2").FormulaLocal = "=I9"
MsgBox "Die vorläufige Bonusabrechnung wurde erfolgreich erstellt!", vbInformation, "PDF erzeugen"
With Application
.ScreenUpdating = True
.EnableEvents = True
.Calculation = xlCalculationAutomatic
End With
End Sub