View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
voodooJoe voodooJoe is offline
external usenet poster
 
Posts: 43
Default Need to perform the same macro to multiple xls files in VB2005 Exp

try something like

Sub x()
strFolder = "c:\"
strFileType = "xls"

If Right(strFolder, 1) < "\" Then strFolder = strFolder & "\"
f = Dir(strFolder & "*." & strFileType)

Do While f < ""
Set wb = Workbooks.Open(strFolder & f)
Debug.Print wb.Worksheets(1).Name 'do stuff - wb will be the
workbook object
wb.Close
f = Dir()
Loop

Set wb = Nothing
End Sub

remember to turn off screen updating

rgds- voodooJoe


"Jhcorsair" wrote in message
...
How do I "loop" through multiple files in a folder to perform the same
task
to each file?