Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Stop a macro call procedure Hi, I have used a process were I place all the macro

ID: 3560960 • Letter: S

Question

Stop a macro call procedure

Hi,

I have used a process were I place all the macros within the sheet I am going to use and then I call any macro I need so that a procedure will take place. The thing is I have created a userform also so that on running this procedure the userform pops up first, and within this userform I have added a command button cancel but still if the userform is cancelled the procedure will still take place. So how could i use a macro that once I hit cancel all the other calling macros will stop and not continue the procedure. Also i have tried using the application.enable events = False but still the procedure continues.

Thanks

Explanation / Answer

%The command End will stop all processing. It also closes the Userform.,/.

Example of button to stop all processing.^%#3

Private Sub CommandButton1_Click()
    End
End Sub

The other way is to declare a Public variable at the top of a standard module before any subs like the following.

Public StopCalls As Boolean 'Place at top of standard module before any subs

Sub visa_print_procdure()
    StopCalls = False
    Call userform_show
    If StopCalls = False Then
        Call Visa_date_selection_print
        Call visa_printer_selection
        Call visa_print_form_clear
        Call visa_ranges_clear
        Call protect_visa_activity
    End If
End Sub

Following sub for command button to Cancel processing

Private Sub CommandButton1_Click()
    StopCalls = True
End Sub

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote