ich kann die Dateien in einem Ordner einlesen, aber wie vergleiche ich sie mit einer Liste?
Fals in der Liste der Dateiname auftaucht wird der betreffende Dateiname nicht eingelesen.
https://www.herber.de/bbs/user/103718.xlsm
Sub Datei()
Dim sPfad As String, sFile As String, i As Long, x As Long, a As Long, LastRow As Long
sPfad = ThisWorkbook.Path
sFile = Dir(sPfad & "\*.xls*")
With Sheets("Tabelle2")
LastRow = .Cells(Rows.Count, 1).End(xlUp).Row
Do While sFile ""
For a = 1 To LastRow
If .Cells(a, 1).Value "" Then
If sFile = .Cells(a, 1).Value Then
Exit For
Else
i = i + 1
Cells(i, 1) = sFile
Exit For
End If
End If
Next a
sFile = Dir
Loop
End With
End Sub
Servus
Sub Datei()
Dim sPfad$, sFile$, i As Long, x As Long, a As Long, z As Long, LastRow As Long, sWkbName$
sPfad = ThisWorkbook.Path
sFile = Dir(sPfad & "\*.xls*")
With Sheets("Tabelle2")
LastRow = .Cells(Rows.Count, 1).End(xlUp).Row
Do While sFile ""
For a = 6 To LastRow
For x = 6 To LastRow
If sFile = .Cells(x, 1).Value Then GoTo nextsFile
Next x
i = i + 1
Cells(i, 1) = sFile
Exit For
Next a
nextsFile: sFile = Dir
Loop
End With
End Sub
Servus