Macros schneller machen
07.08.2014 08:17:36
Bon
Ich habe einen Code um Zeilen in einer großen Excel-Datei zu löschen. Leider dauert es sehr lange, obwohl ich bereits ScreenUpdating = False eingefügt habe.
Habt ihr eine Idee, wie man es schneller machen könnte?
Sub ZeilenLoeschenaktuellesMonat()
Dim Zeile%
Dim x
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
.EnableEvents = False
End With
Sheets("aktuelles_Monat").Select
For Zeile = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row To 1 Step -1
If Cells(Zeile, 10) = "a" Then x = 1 'wenn Zelle leer
If Cells(Zeile, 10) = "b" Then x = 1 'wenn Zelle =?
If Cells(Zeile, 10) = "c" Then x = 1
If Cells(Zeile, 10) = "d" Then x = 1
If x = 1 Then
ActiveSheet.Rows(Zeile & ":" & Zeile).Delete
x = 0
With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
.EnableEvents = True
End With
End If
Next
End Sub
Sub ZeilenLoeschenVormonat()
Dim Zeile%
Dim x
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
.EnableEvents = False
End With
Sheets("Vormonat").Select
For Zeile = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row To 1 Step -1
If Cells(Zeile, 10) = "a" Then x = 1 'wenn Zelle leer
If Cells(Zeile, 10) = "b" Then x = 1 'wenn Zelle =?
If Cells(Zeile, 10) = "c" Then x = 1
If Cells(Zeile, 10) = "d" Then x = 1
If x = 1 Then
ActiveSheet.Rows(Zeile & ":" & Zeile).Delete
x = 0
With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
.EnableEvents = True
End With
End If
Next
End Sub