|
B2に入れる抽出条件をカンマ区切りで複数入れて
それをSplitで分割し、Loopでそれを回したら
Option Explicit
Public Sub Test()
Dim vntF As Variant
Dim objFS As FileSearch
Dim objFSO As FileSystemObject
Dim dteDate As Date
Dim GYO As Long
Dim cntFound As Long
Dim i As Long
Dim vntPath As Variant
Dim vntFileNames As Variant
dteDate = DateAdd("m", Cells(3, 2).Value * -1, Date)
vntPath = Trim(Cells(1, 2).Value)
vntFileNames = Trim(Cells(2, 2).Value)
Rows("5:65536").ClearContents
If vntFileNames = "" Then
GoTo Wayout
End If
vntFileNames = Split(vntFileNames, ",")
Set objFS = Application.FileSearch
Set objFSO = New FileSystemObject
GYO = 4
With objFS
For i = 0 To UBound(vntFileNames)
.NewSearch
.LookIn = vntPath
.Filename = vntFileNames(i)
.SearchSubFolders = True
If .Execute() <> 0 Then
For Each vntF In .FoundFiles
With objFSO.GetFile(vntF)
If .DateLastModified >= dteDate Then
GYO = GYO + 1
Cells(GYO, 1).Value = .Name
Cells(GYO, 2).Value = .DateLastModified
Cells(GYO, 3).Value = _
Left(.Path, Len(.Path) - Len(.Name) - 1)
cntFound = cntFound + 1
End If
End With
Next vntF
End If
Next i
End With
Wayout:
Set objFS = Nothing
Set objFSO = Nothing
End Sub
|
|