0

My macro seems to stop running while trying to open multiple excel workbooks which also contain macro's in them, those macro's which I don't want to run.

Down below is the code that I am using and where it is failing.

Option Explicit
Sub CompleteSummary()
Dim wb As Workbook: Set wb = ThisWorkbook
Dim lwb1 As Workbook
Dim lwb2 As Workbook
Dim lwb3 As Workbook
Dim lwb4 As Workbook
Dim fwb1 As Workbook
Dim fwb2 As Workbook
Dim fwb3 As Workbook
Dim fwb4 As Workbook
Dim x As Workbook
Dim y As Workbook
Dim sht As Worksheet
Dim Sshts As Variant
Dim Ssht As Variant
Dim lr As Long
Dim rRange As Range
Dim i As Integer
Dim mFormula
Dim f As String
Dim s As String
Dim a As String
Dim aa As String
Dim l1 As String
Dim l2 As String
Dim l3 As String
Dim l4 As String
Dim l5 As String
Dim l6 As String
Dim l7 As String
Dim l8 As String
Dim f1 As String
Dim f2 As String
Dim f3 As String
Dim f4 As String
Dim f5 As String
Dim f6 As String
Dim f7 As String
Dim f8 As String

Application.DisplayAlerts = False
Application.AskToUpdateLinks = False
Application.EnableEvents = False

s = Range("Summary").Value
a = Range("lmmALL").Value
aa = Range("lAname").Value

l1 = Range("ALLTemplate").Value
l2 = Range("GBPTemplate").Value
l3 = Range("EURTemplate").Value
l4 = Range("USDTemplate").Value
l5 = Range("OALLTemplate").Value
l6 = Range("OGBPTemplate").Value
l7 = Range("OEURTemplate").Value
l8 = Range("OUSDTemplate").Value


f1 = Range("newf1").Value
f2 = Range("newf2").Value
f3 = Range("newf3").Value
f4 = Range("newf4").Value
f5 = Range("oldf1").Value
f6 = Range("oldf2").Value
f7 = Range("oldf3").Value
f8 = Range("oldf4").Value
        
Application.StatusBar = "Opening" & s

Set x = Workbooks.Open(s, ReadOnly:=True)


Application.StatusBar = "Opening" & l1


Set lwb1 = Workbooks.Open(l1, ReadOnly:=True)


Application.StatusBar = "Opening" & l2


Set lwb2 = Workbooks.Open(l2, ReadOnly:=True)

Application.StatusBar = "Opening" & l3


Set lwb3 = Workbooks.Open(l3, ReadOnly:=True)

Application.StatusBar = "Opening" & l4

Set lwb4 = Workbooks.Open(l4, ReadOnly:=True)

My code fail's on set lwb3 as in it opens lwb2 and then the macro seems to just stop, no error message or anything but it just stops running.

Workbooks lwb1, lwb2, l2b3 and lwb4 also have macro's in them but I don't use those macro's while running mine.

I feel the macro's in those workbooks are popping up and stopping my main macro from no working. Anyway to fix this problem or should I try to select my main macro workbook after every opening?

5
  • Set a break point at Application.StatusBar = "Opening" & l4 and try running it Commented Nov 2, 2020 at 10:17
  • Workbooks, X, lwb1 and lwb2 open and then in the step in screen before it can even get to set lwb3 as soon as lwb2 open's it jump's into the step in screen for the macro in that workbook and the macro stops running it's course Commented Nov 2, 2020 at 10:31
  • How are you running the code? Commented Nov 2, 2020 at 10:39
  • I'm currently doing ctrl and F8 at each statement so not trying to run it all at the same time Commented Nov 2, 2020 at 10:41
  • I've found the answer. For anyone that is interested stackoverflow.com/questions/51888282/… Commented Nov 2, 2020 at 11:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.