Code schneller machen
09.03.2017 09:46:51
Volker
bin neu hier und brauch eure Hilfe.
Ich muss große Datenmengen aus einer Datei in eine andere Kopieren.
Verwende diesen Code, der auch funktioniert, aber bei großen Mengen eben ziemlich langsam ist.
Gibt es irgendeine Möglichkeit dies zu beschleunigen?
Danke für eure Hilfe.
Volker
Sub SLSCockpit_Schaltfläche1_Klicken()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Worksheets("SLS Cockpit").Range("A33:CP50000").Clear
Worksheets("SLS Cockpit").Range("CQ34:CY50000").ClearContents
Dim WBZiel As Workbook, ExportDatei As Variant, WBQuelle As Workbook, WSZiel As Worksheet
Set WBZiel = ThisWorkbook
ExportDatei = Application.GetOpenFilename("\\brose.net\users\KOP\homet\ttkrebs\UserDir\ _
Desktop\Tabelle von Basis (1).xlsx", "Bitte die Datei zum Kopieren öffnen ...")
ExportDatei = CStr(ExportDatei)
If ExportDatei = "Falsch" Then Exit Sub
Set WBQuelle = Workbooks.Open("\\brose.net\users\KOP\homet\ttkrebs\UserDir\Desktop\Tabelle _
von Basis (1).xlsx")
With WBQuelle
.Sheets("Tabelle1").Range("A2:CP50000").Copy WBZiel.Sheets("SLS Cockpit").Range("A33: _
CP50000")
.Close savechanges:=False
End With
WBZiel.Sheets("SLS Cockpit").Activate
Dim z As Long
Dim s As Long, lPruefSpalte As Long
lPruefSpalte = 1
With ActiveSheet
For z = .UsedRange.Row To .UsedRange.Row + .UsedRange.Rows.Count - 1
If z > .UsedRange.Row + 1 And Trim(CStr(.Cells(z, lPruefSpalte).Value)) "" _
Then
For s = .UsedRange.Column To .UsedRange.Column + .UsedRange.Columns.Count - 1
If .Cells(z - 1, s).HasFormula = True And .Cells(z, s).HasFormula = False _
_
Then
.Cells(z, s).FormulaR1C1 = .Cells(z - 1, s).FormulaR1C1
End If
Next s
End If
Next z
End With
Dim pc As PivotCache
For Each pc In ActiveWorkbook.PivotCaches
pc.Refresh
Next
Application.ScreenUpdating = True
Application.Calculation = LoBerechnung
Call Calculate
MsgBox "Import successful!"
End Sub