View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Steve Yandl Steve Yandl is offline
external usenet poster
 
Posts: 284
Default Finding specific excel files

Not a tweak of what you have because it doesn't use 'Dir' but here is an
alternate approach. This will reveal all the files in C:\Test with xls
extensions and the first character the digit 1.

_______________________________

Dim strPath As String

strPath = "C:\Test"

Set FSO = CreateObject("Scripting.FileSystemObject")
Set fldr = FSO.GetFolder(strPath)

For Each myFile In fldr.Files
If FSO.GetExtensionName(myFile) = "xls" _
And Left(FSO.GetBAseName(myFile), 1) = "1" Then
MsgBox myFile.Name
End If
Next myFile

Set fldr = Nothing
Set FSO = Nothing

______________________________

Steve Yandl



wrote in message
...
I have the following to find files in a folder with .xls extension.

Dim MyPath As String
FilesInPath = Dir(MyPath & "*.xls")

How would tweak this to find excel files that start with "1_"?

Any help would be much appreciated!

Kevin