Hello, I am using a modified version of code that normally has a "FolderPicker" to (1) open all workbooks in a designated folder and (2) to run a macro found in the other workbooks.
Instead of the FolderPicker I just pointed myPath to a range which inludes "\" at the end of the path.
I run into a problem when I run this macro 2nd time. 1st time it goes through the entire macro fine and it does what it's supposed to, but second run it stops at
. The only way to run the macro 2nd time is to close the workbook and reopen it as something seems to reset.
I have same macro to load Forecast and cannot load it after Budget unless I close the workbook and reopen.
I should point out that if I leave FolderPicker in place, I can load multiple times with no issues.
thank you for any insight...
Instead of the FolderPicker I just pointed myPath to a range which inludes "\" at the end of the path.
I run into a problem when I run this macro 2nd time. 1st time it goes through the entire macro fine and it does what it's supposed to, but second run it stops at
Code:
Set wb = Workbooks.Open(myPath & myFile)
I have same macro to load Forecast and cannot load it after Budget unless I close the workbook and reopen.
I should point out that if I leave FolderPicker in place, I can load multiple times with no issues.
thank you for any insight...
VBA Code:
Sub ImportBudget()
Dim wb As Workbook
Dim myPath As String
Dim myFile As String
Dim myExtension As String
With Application
.ScreenUpdating = False
.EnableEvents = False
.Calculation = xlCalculationManual
End With
myPath = Range("SourcePath")
If Dir(myPath) <> "" Then
NextCode:
myPath = myPath
If myPath = "" Then GoTo ResetSettings
myExtension = "*.xls*"
myFile = Dir(myPath & myExtension)
Do While myFile <> ""
Set wb = Workbooks.Open(myPath & myFile)
DoEvents
wb.Worksheets("Menu").Select
Application.Run "'" & wb.Name & "'!Load_Budget"
wb.Close SaveChanges:=True
DoEvents
myFile = Dir
Loop
End If
MsgBox "Import Complete!"
ResetSettings:
With Application
.EnableEvents = True
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
Set wb = Nothing
ThisWorkbook.Save
End Sub