Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50139

How to force long loops to end

$
0
0
I've been looking for a simple solution for the title question and I became an expert at everything, but! Up until 20 minutes ago, that is and I want to share the solution:
Code:

Option Explicit
Dim DROP_DEAD          As Boolean
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub kill_macros()
DROP_DEAD = True
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function END_CHK()
    DoEvents
    END_CHK = False

    If DROP_DEAD = True Then
        Range("macro_msgs").Value = "R.I.P." 'Indicate the macro end to the spreadsheet above
        END_CHK = True
    End If
End Function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub fill_in_the_blanks()
Dim i As Long
i = 0
loop_top: i = i + 1
'''
'''
'''
'''
If END_CHK Then Exit Sub
Goto loop_top
End Sub

Hope it works for all as well as it works for me! I made a text box in the spreadsheet and linked it kill_macros. One click and I see the R.I.P. message in cell macro_msgs!!

Viewing all articles
Browse latest Browse all 50139

Trending Articles