jono19872006
08-15-2012, 07:19 AM
I have simplified my code down a lot but below is some code i have which loops through a folder and then formats the documents inside.
However what i use it for is to edit reports and i want to at times do more than one months worth of reports (these by default have the same name)
As such is there a way where i could either specify two files paths which the code would look in and loop through or how could i adjust the below so that It looks at the foder then loops through down into the subfolders?
Dim fPath As String
Dim fName As String
Dim wb As Workbook
Application.ScreenUpdating = False
fPath = "ad\store\Personal\M\maginj90\MACROTEST\"
fName = Dir(fPath & "*.xls") 'start a list of filenames
Do While Len(fName) > 0
Set wb = Workbooks.Open(fPath & fName) 'open found file
'Formats
Range("A1").Value = Now()
Range("A2").Value = "34535s"
'looping round
Application.DisplayAlerts = False
wb.Close True 'close/save
Application.DisplayAlerts = True
fName = Dir 'get next filename
Loop
Application.ScreenUpdating = True
End Sub
thanks
jon
However what i use it for is to edit reports and i want to at times do more than one months worth of reports (these by default have the same name)
As such is there a way where i could either specify two files paths which the code would look in and loop through or how could i adjust the below so that It looks at the foder then loops through down into the subfolders?
Dim fPath As String
Dim fName As String
Dim wb As Workbook
Application.ScreenUpdating = False
fPath = "ad\store\Personal\M\maginj90\MACROTEST\"
fName = Dir(fPath & "*.xls") 'start a list of filenames
Do While Len(fName) > 0
Set wb = Workbooks.Open(fPath & fName) 'open found file
'Formats
Range("A1").Value = Now()
Range("A2").Value = "34535s"
'looping round
Application.DisplayAlerts = False
wb.Close True 'close/save
Application.DisplayAlerts = True
fName = Dir 'get next filename
Loop
Application.ScreenUpdating = True
End Sub
thanks
jon