Hello Ben,
Welcome to the Forum!
This macro will search a folder for all files that have match this pattern "_yy/mm/dd.txt". The matching files will be listed on "Sheet1" starting with cell "A1". Change the worksheet and file path in the macro to what you want to use. They are marked in bold.
![]()
'Written: July 14, 2010 'Author: Leith Ross 'Summary: Lists files on a worksheet in column "A" that match a pattern. Sub ListFileNames() Dim FileName As String Dim FilePath As String Dim Valid As Boolean Dim Wks As Worksheet R = 1 'Starting Row Set Wks = Worksheets("Sheet1") FilePath = "C:\\My Documents\" & "*.txt" FileName = Dir(FilePath) Do While FileName <> "" Valid = FileName Like "*_##/##/##.txt" If Valid Then If Mid(FileName, 6, 5) = Acct Then Wks.Cells(R, "A") = FileName R = R + 1 End If End If FileName = Dir Loop End Sub











LinkBack URL
About LinkBacks
Register To Reply

Bookmarks