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.
 

Some videos you may like

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
50,930
Office Version
  1. 365
Platform
  1. Windows
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
 

wling1

New Member
Joined
Aug 26, 2014
Messages
3
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!
 

Watch MrExcel Video

Forum statistics

Threads
1,118,875
Messages
5,574,762
Members
412,617
Latest member
mlharris
Top