Hallo M.O
Danke für die Antwort!
Aber irgendwie funktioniert der Code generell nicht.
Deswegen meine Frage an die Profis:
Wie muss ich diesen Code:
Do While strFileName <> ""
If datTime < FileDateTime(strPath & strFile) Then
datTime = FileDateTime(strPath & strFile)
strFileNew = strFileName
End If
strFileName = Dir$()
Loop
If strFileNew <> "" Then Workbooks.Open strPath & strFileNew
Fin:
If Err.Number <> 0 Then MsgBox "Error: " & _
Err.Number & " " & Err.Description
In diesen Code:
Option Explicit
Public Sub Test()
Dim strFileName As String
Dim strFileNew As String
Dim strPath As String
Dim intTMP As Integer
Dim datTime As Date
On Error GoTo Fin
strPath = "C:\Temp\" ' anpassen!!!
Application.ScreenUpdating = False
intTMP = 1
strFileName = Dir$(strPath & "*.xlsx*")
If Right(strPath, 1) <> "\" Then strPath = strPath & "\"
Do While strFileName <> ""
If Not strFileName = ThisWorkbook.Name Then
Workbooks.Open (strPath & strFileName)
With ActiveWorkbook
.Worksheets(1).Copy _
After:=ThisWorkbook.Worksheets _
(ThisWorkbook.Worksheets.Count)
.Close False
With ThisWorkbook
.Worksheets(.Worksheets.Count).Name = "Auftragsliste" & intTMP
End With
intTMP = intTMP + 1
End With
strFileName = Dir$()
Else
strFileName = Dir$()
End If
Loop
Fin:
Application.ScreenUpdating = True
End Sub
einbinden, damit die Codes zusammen funktioniert.
Ich möchte, dass der immer die neueste Excel Datei aus einem Verzeichnis in eine andere Excel Liste kopiert.
[u]Beispiel:[/u ]Also sagen wir, ich habe ein Excel Datei von gestern in Ordner A und möchte diese in der Tabelle haben, in der ich das Makro ausführe.
VG
Simon