VBA to disable a sub within a module from running

p4nny

Board Regular
Joined
Jan 13, 2015
Messages
246
Hi

I would like to use a pop prompt to disable a particular sub within a module from running?

The prompt would appear on opening of the workbook. If the user clicks "No" this would disable the sub from running.

Is this possible to achieve?

Many thanks
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Something like this within the ThisWorkbook module:

Code:
Private Sub Workbook_Open()

If MsgBox("Do you want to run macro?", vbYesNo) = vbYes Then
    Call macro1
End If

End Sub
 
Upvote 0
Thanks Steve,

Apologies I don't think I was clear originally

There is one master macro which runs several other macros (using Call..) and the user does this by clicking a button. It is one the other sub macros that I need disabling if possible on opening.

thanks again, and hope I'm being clearer
 
Upvote 0
What do you need running if i open the workbook and click no?

What do you need running if i open the workbook and click yes?

If it isnt needed in a open event its best to do that via the button click.
 
Upvote 0

Forum statistics

Threads
1,213,504
Messages
6,114,016
Members
448,543
Latest member
MartinLarkin

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