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.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
31,992
Office Version
365
Platform
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!
 

Forum statistics

Threads
1,081,556
Messages
5,359,547
Members
400,533
Latest member
fpenning

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top