Perhaps you mean
eg:![]()
End
![]()
Sub one() Call two Call three End Sub Sub two() If MsgBox("Quit", vbYesNo) = vbYes Then End End Sub Sub three() MsgBox "Invoked" End Sub
Perhaps you mean
eg:![]()
End
![]()
Sub one() Call two Call three End Sub Sub two() If MsgBox("Quit", vbYesNo) = vbYes Then End End Sub Sub three() MsgBox "Invoked" End Sub
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
i have tried this but by using end in in sub two sub three is still called. End only works on that sub and the sub one will then continue to excecute the rest of the code after it
Without seeing your own code it's hard to pass comment, but using my example - if you run Sub one() and click "Yes" on subsequent MsgBox Sub three() is not invoked (no "Invoked" dialog is generated).
This is the code for the main sub
here is the code for the user form![]()
Private Sub CommandButton1_Click() Dim click As Integer Dim response As Integer click = ActiveSheet.Range("Z1") click = click + 1 ActiveSheet.Range("Z1") = click UserForm1.Show If response = 1 Then Exit Sub End If Call NotifyDepartments(click) End Sub
![]()
Private Sub UserForm_Deactivate() response = 1 End Sub
how do pass response back from the form to the main sub
Last edited by boc_est1986; 08-18-2009 at 06:36 AM. Reason: post did not comply with rule #3 of the forum rules
You would use the Terminate Event, ie:
No need to pass variable back to main routine if you intend to just exit the code altogether.![]()
Private Sub UserForm_Terminate() End End Sub
ok thanks its working now
Be careful of the use of End. It will reset all module/project level variables.
The problem is that the response variable is local to the caller routine.
You either need to use a public variable or a private variable within the userform that you can read.
public variable approach.
![]()
Public response As Integer Private Sub CommandButton1_Click() Dim click As Integer click = ActiveSheet.Range("Z1") click = click + 1 ActiveSheet.Range("Z1") = click UserForm1.Show If response = 1 Then Exit Sub End If Call NotifyDepartments(click) End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks