ich habe eben folgenden Makro Code bekommen. Dieses Makro soll Dateien auslesen. Ich habe diesen Code selber nicht geschrieben, er soll aber optimiert werden, da dieses Makro bei einem großen Datenatz sehr lange durchläuft. Kann mir irgendjemand helfen?
Vielen Dank im Voraus!
Sub Makro1()
'Alle xlsx-Dokumente in ein Array einlesen
Dim lngAnzahl As Long
Dim strDatei As String
Dim strDateien() As String
strDatei = Dir(ThisWorkbook.Path & "\*.xls")
Do While Len(strDatei)
If strDatei ThisWorkbook.Name Then
lngAnzahl = lngAnzahl + 1
ReDim Preserve strDateien(1 To lngAnzahl)
strDateien(lngAnzahl) = strDatei
End If
strDatei = Dir
Loop
Dim datei_anzahl As Integer
'Anzahl Dateien in Array zählen
datei_anzahl = UBound(strDateien, 1) - LBound(strDateien, 1) + 1
'Datei auslesen
For i = 1 To datei_anzahl
objectname = ThisWorkbook.Path & "\" & strDateien(i)
Dim objexcel As New Excel.Application
Dim objsheet As Object
objexcel.Workbooks.Open objectname
Set objsheet = objexcel.Sheets(1)
s = i + 4
Cells(1, s) = strDateien(i)
Dim loletzte As Long
loletzte = IIf(IsEmpty(Cells(Rows.Count, 1)), Cells(Rows.Count, 1).End(xlUp).Row, Rows. _
Count)
For j = 2 To loletzte
Dim loLetzte2 As Long
loLetzte2 = IIf(IsEmpty(objsheet.Cells(Rows.Count, 1)), objsheet.Cells(Rows.Count, 1). _
_
End(xlUp).Row, objsheet.Rows.Count)
For k = 2 To loLetzte2
If Cells(j, 1) = objsheet.Cells(k, 1) Then
Cells(j, s) = objsheet.Cells(k, 3)
Else
End If
Next
Next
objexcel.EnableEvents = False
objexcel.DisplayAlerts = False
'objexcel.ActiveWorkbook.SaveAs objectname
objexcel.ActiveWorkbook.Close savechanges:=False
objexcel.Quit
Set objexcel = Nothing
Set objsheet = Nothing
Next
End Sub