Only first Call method is being executed when module is ran.

Avocado87

New Member
Joined
Feb 22, 2021
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I have module1 which when ran is supposed to:
  1. Set variable "template"
  2. Call 6 different Sub's with "template" as argument
The 6 subs all work perfectly when ran individually but when I try to use the Call method to run them only the first one gets ran, the other 5 never get executed. All 6 are Private Sub's and are in the same module. I have been looking all day for an answer and can't figure out why only the first one runs. If I comment out the first sub then only the second one runs, if I comment out the first and second only the 3rd runs and so forth, so this tells me they all work, but don't know what they aren't all being called. Any help would be greatly appreciated.

Example:

Sub module1()

tempFileName = Environ("Temp")& "\" & generate_guid()
Application.Workbooks.Open("PATH").SaveAs tempFileName
Set template = Application.Workbooks.Open(tempFileName)

Call miles(template)
Call names(template)
Call prequal(template)
Call cars(template)
Call trucks(template)
Call dates(template)

End Sub

Private Sub miles(ByRef template As Workbook)
...
code
...
End Sub

Private Sub names(ByRef template As Workbook)
...
code
...
End Sub

Private Sub prequal(ByRef template As Workbook)
...
code
...
End Sub
...
...
(and so on for the other 3 Private Sub's)


I think I included all information that I believe might be causing the issue. Any help with this would be greatly appreciated.

Thanks!
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Welcome to the Board!

Did you try adding in break points, and stepping through your code so you can see what happens?
I think it may be helpful to us to see all the code of your first module, to see if there is something in there that is "killing" it.

Also, did you really name your procedure "module1"?
I would not recommend that. Modules are containers that hold VBA code. So to name a VBA procedure "module1" is very confusing.
When you add modules, that is how Excel names them by default.
You basically should avoid naming your procedures, functions, and variables key words that are used for things like built-in Excel functions, properties, and methods.
I doubt that is the cause of your issues, but it would be good to totally eliminate that possibility by choosing a different name.
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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