Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to stop subsequent procedure calls from executing? 2

Status
Not open for further replies.

makeitwork09

Technical User
Sep 28, 2009
170
0
0
US
I am using Excel 2007. The following code has multiple calls, however, if
the first procedure  (second set of code) gets to the Exit Sub point, I do
not want the rest of the procedure calls to execute. I have looked through
a couple of books that I have and I have searched the web, but I have yet
to figure out how to get the subsequent procedure calls not to execute?

Code:
Private Sub cmdCreateCFMaturities_Click()

   Call Module1.checkInt
   Call Module2.CopyFilter
   Call Module2.MaturitiesPivotTable
   Call Module2.CashFlowPivotTable
   Call MoveSheets

End Sub

In module 1 I have the following, which, if there is an error, I do not
want the procedures after Call Module1.checkInt to execute.

Code:
Sub checkInt()
   Dim ValidPSA

   ValidPSA = Application.InputBox(prompt:="Enter the most recent PSA",
Type:=1)

    On Error Resume Next
   'exit if user selects Cancel..assisted from PHV on [URL unfurl="true"]www.tek-tips.com[/URL]
thread707-1643026
    If ValidPSA = False Then
        Exit Sub 'I need this to be the stopping point; no more calls
should execute
    Else
       If IsNumeric(ValidPSA) Then
          'int function rounds number, if it equals the cell, then number
is an interger
          If ValidPSA > 0 And ValidPSA - Int(ValidPSA) = 0 Then
              Call CashflowQuery(ValidPSA)
          Else
              MsgBox "Not a Positive Integer: " & ValidPSA
              Exit Sub 'I need this to be the stopping point; no more
calls should execute
          End If
       End If
    End If

End Sub

Thanks in advance
 



hi,

Make your prodecures FUNCTIONS instead.

In the function code, if the cancel is selected then assign the function as FALSE, otherwise TRUE.
Code:
function checkInt() as boolean
   
    If ValidPSA = False Then
        checkInt = false
        Exit Sub 'I need this to be the stopping point; no more calls
    else
        checkInt = true
    end if
should execute

end function
In your MAIN
Code:
Private Sub cmdCreateCFMaturities_Click()

   if checkInt then
      Call Module2.CopyFilter
      Call Module2.MaturitiesPivotTable
      Call Module2.CashFlowPivotTable
      Call MoveSheets
   end if

End Sub


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top