View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tim Williams Tim Williams is offline
external usenet poster
 
Posts: 1,588
Default Choose particular files from a directory

Sub ProcessFiles()

dim sPath

sPath=Dir("Y:\Sales\2005\REGION***.xls")

do while sPath<""
ProcessFile sPath
sPath=Dir()
loop

'process the other two files
ProcessFile "Y:\Sales\2005\ABC.xls"
ProcessFile "Y:\Sales\2005\DEF.xls"

end sub


Sub ProcessFile(sPath as string)
'process workbook code goes here
end sub


Tim.


--
Tim Williams
Palo Alto, CA


"JEFF" wrote in message
...
Hello,

Per the below, I'm trying to manipulate certain files within a directory.
As you can see in the last line, I am unsuccessfully trying to choose all
files in the directory entitled "Region***", as well as two specific files
("ABC.xls", "DEF.xls"). It works with just the Region, but not sure how

to
get the syntax right to get the last two as well.....


TIA!




Dim basebook As Workbook
Dim mybook As Workbook
Dim sourceRange As Range
Dim destrange As Range
Dim rnum As Long
Dim SourceRcount As Long
Dim FNames As String
Dim MyPath As String
Dim SaveDriveDir As String

SaveDriveDir = CurDir

MyPath = "Y:\Sales\2005"
ChDrive MyPath
ChDir MyPath

FNames = Array(Dir("REGION***.xls"), "ABC.xls", "DEF.xls")