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?)
 

Some videos you may like

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
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,
 

shadow12345

Well-known Member
Joined
May 10, 2004
Messages
1,238
i can't believe its that simple... end...


Idiot.


Thanks for you help.
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,365
Messages
5,510,868
Members
408,816
Latest member
ashcraft

This Week's Hot Topics

  • Turn fraction around
    Hello I need to turn a fraction around, for example I have 1/3 but I need to present as 3/1
  • TIme Clock record reformatting to ???
    Hello All, I'd like some help formatting this (Tbl-A)(Loaded via Power Query) [ATTACH type="full" width="511px" alt="PQdata.png"]22252[/ATTACH]...
  • TextBox Match
    hi, I am having a few issues with my code below, what I need it to do is when they enter a value in textbox8 (QTY) either 1,2 or 3 the 3 textboxes...
  • Using Large function based on Multiple Criteria
    Hello, I can't seem to get a Large formula to work based on two criteria's. I can easily get a oldest value based one value, but I'm struggling...
  • Can you check my code please
    Hi, Im going round in circles with a Compil Error End With Without With Here is the code [CODE=rich] Private Sub...
  • Combining 2 pivot tables into 1 chart
    Hello everyone, My question sounds simple but I do not know the answer. I have 2 pivot tables and 2 charts that go with this. However I want to...
Top