If end sub

  • Thread starter Thread starter Miree
  • Start date Start date
M

Miree

So far I have the following code, It needs to carry out the furthur code if
Yes or No selected, I want the selection of Cancel to just close msg box and
end the sub.

Response = MsgBox("Do you want to Print?", vbYesNoCancel)
If Response = vbYes Then
Range("A1:K41").PrintOut

End If

furthur code
 
Hi,

Try this

Sub Marine()
response = MsgBox("Do you want to Print?", vbYesNoCancel)
If response = vbYes Then
Range("A1:K41").PrintOut
ElseIf response = vbNo Then
MsgBox "You pressed no"
'Do things
ElseIf response = vbCancel Then
MsgBox "You pressed cancel"
'do different things
End If

End Sub

Mike
 
Sorry missed the bit about exit sub

Sub Marine()
response = MsgBox("Do you want to Print?", vbYesNoCancel)
If response = vbYes Then
Range("A1:K41").PrintOut
ElseIf response = vbNo Then
MsgBox "You pressed no"
'Do things
ElseIf response = vbCancel Then
MsgBox "You pressed cancel"
Exit Sub
End If

End Sub
 
This doesn't really help

The furthur code is quite large and needs to run for both yes and no, after
printing.

I just need to exit the sub if user selects cancel
 
For that you only need to check the cancel button.

Sub Marine()
response = MsgBox("Whatever message you want", vbYesNoCancel)
If response = vbCancel Then
Exit Sub
End If
'lots on lots of code
End Sub

Mike
 
Back
Top