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

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

JGordon11

Board Regular
Joined
Jan 18, 2021
Messages
168
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
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
 

Forum statistics

Threads
1,141,203
Messages
5,704,941
Members
421,372
Latest member
Jamie11

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
Top