exit all vba?

shadow12345

Well-known Member
Joined
May 10, 2004
Messages
1,238
I have a rather large macro that controls a number of functions. I have just been informed that one the things I evualate should cause the entire process to stop if it equals "F".

I know the Exit sub command, but this proceedure is called from within others, I am wondering if I can stop all macros running without having to evaulate the variable right at the start of the macro. Example below


Sub selectcorrectstyle()

Dim contract As String
Dim exchange As String
Dim ref
Dim contracttype As String
Dim contracttypefind As Long
Sheets("Current day").Select
ref = Range("a1")
contracttype = Mid(ref, 2, 1)
contracttypefind = InStr(1, ref, contracttype)


exchange = Left(ref, 1)
'contract = mid(ref,(instr(1,ref,contracttype)
contract = Trim(Mid(ref, contracttypefind + 1))

If contracttype = "O" Then Exit Sub
If contracttype = "F" Then MsgBox "other procedure call goes here"

End Sub

How could insted of exit sub, have exit all macros? (or am I stuck and ill have to check this earlier?)
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Try:

If contracttype = "F" Then End

Here's an example:

<font face=Calibri><SPAN style="color:#00007F">Sub</SPAN> foo()<br>    <SPAN style="color:#00007F">Call</SPAN> macro1<br>    MsgBox "foo"<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br><br><SPAN style="color:#00007F">Sub</SPAN> macro1()<br>    MsgBox "End"<br>    End<br>End <SPAN style="color:#00007F">Sub</SPAN><br></FONT>

HTH,
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,918
Members
449,093
Latest member
dbomb1414

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