Macro at Startup

JTL9161

Well-known Member
Joined
Aug 29, 2012
Messages
567
Office Version
  1. 365
Platform
  1. Windows
I have the below macro in the workbook startup to ask if I want to run the macro in the workbook.

Private Sub Workbook_Open()
CarryOn = MsgBox("Do you want to run the Macro?", vbYesNo)
If CarryOn = vbYes Then
Application.Run Macro:="holding2"
End If
End Sub

After I click "YES" it tells me the macro is not available. Its a separate module in the same spreadsheet. Is there another way to run it or do I need to move all my code over to the workbook startup and all under the msg book question code?

Thanks
James
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Try using
Code:
Call holding2
 
Upvote 0
Now I do not even get the message box. I get "Expected Variable or procedure, not module" error
 
Upvote 0
What is the name of the macro you are trying to run?
 
Upvote 0
What is the first line of the sub where the name is?
 
Upvote 0
Can you please your entire "Holding2" code block?
Also, which module is this code found in?
 
Upvote 0

Forum statistics

Threads
1,215,829
Messages
6,127,130
Members
449,361
Latest member
VBquery757

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