I
intoit
I've been using the macro below, which works a great. However, I would like
to modify the macro such that the directory path does not have to be
specified. That is, instead, the macro would identify the path of the
orginally opened workbook (from which the macro is executed) and then look
within that path for the folder named 'Groups', and then execture the called
macro on all of the workbooks within the Groups folder.
I thought it would be as simple as adding:
Dim MyPath As String
MyPath = Application.ThisWorkbook.path
and
Const path = MyPath & ("Groups") & "\"
....but that didn't work (i.e., debugger says the path can not be found. Any
advice greatly appreciated.
Sub ProcessAllFiles()
Dim sFile$
Const path = "C:\Groups\"
sFile = Dir(path & "*.xls")
Do While sFile <> ""
'the new workbook will become active
Workbooks.Open (path & sFile)
'run your macro here
Call gema_fit_calculations_groups
'however make sure that the new workbook
'remains active throughout the macro
'Macro1
ActiveWorkbook.Close savechanges:=True
sFile = Dir
Loop
End Sub
to modify the macro such that the directory path does not have to be
specified. That is, instead, the macro would identify the path of the
orginally opened workbook (from which the macro is executed) and then look
within that path for the folder named 'Groups', and then execture the called
macro on all of the workbooks within the Groups folder.
I thought it would be as simple as adding:
Dim MyPath As String
MyPath = Application.ThisWorkbook.path
and
Const path = MyPath & ("Groups") & "\"
....but that didn't work (i.e., debugger says the path can not be found. Any
advice greatly appreciated.
Sub ProcessAllFiles()
Dim sFile$
Const path = "C:\Groups\"
sFile = Dir(path & "*.xls")
Do While sFile <> ""
'the new workbook will become active
Workbooks.Open (path & sFile)
'run your macro here
Call gema_fit_calculations_groups
'however make sure that the new workbook
'remains active throughout the macro
'Macro1
ActiveWorkbook.Close savechanges:=True
sFile = Dir
Loop
End Sub