VBA Code - Call a macro and stop the run until certain lines

Johns90

New Member
Joined
Feb 3, 2021
Messages
12
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have a Macro (the name is Test() ) from the Module1, and normally to call this Macro, i am using the code :
Call Module1.Test

But i am looking to a VBA code to call my Macro Test from Module1 until certain lines of code
Example stop the runing when the macro is arriving to the line 900

Thanks for your help
 

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.
Not sure how to do what you're asking for (not sure it's possible).

But here's an approach to stop a code early based on a passed parameter:

VBA Code:
Option Explicit

Sub Test(Optional StopEarly As Boolean = False)
    Dim i As Long
    For i = 1 To 10
        If StopEarly And i > 5 Then
            MsgBox i
            Exit Sub
        End If
    Next
    MsgBox i
End Sub

Sub CallTest()
    Test         'msgbox displays 11
    Test True    'msgbox displays 6
    Test False   'msgbox displays 11
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,559
Members
449,089
Latest member
Motoracer88

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