Hello,
I have a macro that will automatically update all the spreadsheets in a directory. However the macro will not look through folders for spreadsheets. It will only run on the spreadsheets that are sitting in the immediate directory.
So for example my directory to search for spreadsheets.
C:\Update
I have about 50 folders that I pull off of the shared drive to update the spreadsheets that are in these folders. I put them into the C:\Update directory.
So now I have something like:
C:\Update\CIN Region
The problem is I have to open every single folder on the shared drive and paste the spreadsheets directly into the C:\Update directory. It is tedious work and would like a way to just paste all the folders from the shared drive into the update folder. Then run the macro and have it go through those folders and run the update on spreadsheets.
Here is the macro code:
I have a macro that will automatically update all the spreadsheets in a directory. However the macro will not look through folders for spreadsheets. It will only run on the spreadsheets that are sitting in the immediate directory.
So for example my directory to search for spreadsheets.
C:\Update
I have about 50 folders that I pull off of the shared drive to update the spreadsheets that are in these folders. I put them into the C:\Update directory.
So now I have something like:
C:\Update\CIN Region
The problem is I have to open every single folder on the shared drive and paste the spreadsheets directly into the C:\Update directory. It is tedious work and would like a way to just paste all the folders from the shared drive into the update folder. Then run the macro and have it go through those folders and run the update on spreadsheets.
Here is the macro code:
Code:
ub Auto_open_change()
Dim WrkBook As Workbook
Dim StrFileName As String
Dim FileLocnStr As String
Dim LAARNmeWrkbk As String
PERNmeWrkbk = ThisWorkbook.Name
FileLocnStr = "C:\Update\" 'ThisWorkbook.Path
Dim StrFile As String
StrFile = Dir(FileLocnStr & "\*.xlsm")
Do While Len(StrFile) > 0
DoStuff (FileLocnStr & "\" & StrFile)
StrFile = Dir
Loop
End Sub
Private Sub DoStuff(StrFileName)
Workbooks.Open (StrFileName)
'Workbooks(StrFileName).Activate
Call Updateit
'Saves and closes workbook
ActiveWorkbook.RefreshAll
ActiveWorkbook.Save
ActiveWorkbook.Close
End Sub