Workbook open and executing two different macro excel files

wling1

New Member
Joined
Aug 26, 2014
Messages
3
I have two excel files that run macros upon opening. I have an additional "dummy" excel file with the following codes:

Private Sub Workbook_Open()

If InStr(1, ThisWorkbook.Name, "NoRun") > 0 Then
Range("C6").Select
'Do nothing so the macro won't run.

Else
Application.OnTime Now + TimeValue("00:00:05"), "PortsmouthChem"
Application.OnTime Now + TimeValue("00:01:00"), "GloucesterChem"
End If

End Sub

Sub GloucesterChem()
Workbooks.Open Filename:="C:\Users\nphifer\Desktop\Chemistry Reports to GE\DCS-11422-WHEELABRATORGLOUCESTER.xlsm"
End Sub

Sub PortsmouthChem()
Workbooks.Open Filename:="C:\Users\nphifer\Desktop\Chemistry Reports to GE\DCS-11228-WHEELABRATORPORTSMOUTH.xlsm"
End Sub

When I open up the "dummy" file, it will run "PortsmouthChem" but it won't go through it's macros, but instead wait until "GloucesterChem" is executed and it will just run the macros within that. I need a way to have both of them open and run their macros and am kind of stumped. I feel like it should be an easy solution but am having some trouble. Any help is much appreciated.
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Hiya & Welcome to the board.
How about something like this
Code:
Private Sub Workbook_Open()
 
    If Not InStr(1, ThisWorkbook.Name, "NoRun") = 0 Then
        Workbooks.Open Filename:="C:\Users\nphifer\Desktop\Chemistry Reports to GE\DCS-11228-WHEELABRATORPORTSMOUTH.xlsm"
    End If

End Sub
& then add
Code:
Workbooks.Open Filename:="C:\Users\nphifer\Desktop\Chemistry Reports to GE\DCS-11422-WHEELABRATORGLOUCESTER.xlsm"
to the end of the "Portsmouth" code
 
Upvote 0
Thank you for the welcoming! That code helps out definitely. I also was digging through one of the files and realized it had an application quit call that was messing with it as well. Thanks again!
 
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,539
Members
449,038
Latest member
Guest1337

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top