Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How do I "loop" through multiple files in a folder to perform the same task
to each file? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
try something like
Sub x() strFolder = "c:\" If Right(strFolder, 1) < "\" Then strFolder = strFolder & "\" f = Dir(strFolder & "*.xls") 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 don't forget 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? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Run Macro on multiple files | Excel Discussion (Misc queries) | |||
Macro: Filter Multiple header then extract to Multiple Files | Excel Discussion (Misc queries) | |||
Combination chart using VB2005 | Charts and Charting in Excel | |||
Learning VB6 or VB2005? | Excel Programming | |||
Import multiple files macro can't find files | Excel Programming |