How do I exit a macro in Excel?

Hobbe

New Member
Joined
Dec 3, 2005
Messages
2
I'm not talking about exiting a procedure with "Exit Sub" since this will only terminate the procedure I'm currently within. In my case, this means that the next procedure will be called and the macro continues...

Basically, I'm looking for a Ctrl+Break equivalent that can terminate the macro from anywhere within the code.
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Hello Hobbe & welcome to the board.
I'm not sure I understand exactly what you're asking. Is it that you want to call a second macro while in the middle of the first and then resume the first one from that point when the second one is finished?
If so then perhaps this:
Code:
Sub FirstMacro()

'Some code here
'Some more code here

Call SecondMacro

'More FirstMacro code here

End Sub
If this is what you're after then the only consideration now is the compatibility of the two macros together.

(If it isn't what you're after then can you describe in a bit more detail?)
 
Upvote 0
You can use End to stop all code execution.

<html><head><title></title></head><body><table width="642"> <tr vAlign="top"> <th width="90" align="left"><p align="left"><font face="Arial">Statement</font></th> <th width="544" align="left"><font face="Arial">Description</font></th> </tr> <tr vAlign="top"> <td class="T" width="90" align="left"><font face="Arial">End</font></td> <td class="T" width="544" align="left"><font face="Arial">Terminates execution immediately. Never required by itself but may be placed anywhere in a procedure to end code execution, close files opened with the Open statement and to clear variables.</font></td> </tr></table></body></html>
 
Upvote 0

Forum statistics

Threads
1,214,415
Messages
6,119,381
Members
448,888
Latest member
Arle8907

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