Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
If end sub
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
If end sub
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 "Miree" wrote: 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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
If end sub
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 "Mike H" wrote: 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 "Miree" wrote: 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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 "Mike H" wrote: 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 "Miree" wrote: 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 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
If end sub
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 "Miree" wrote: 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 "Mike H" wrote: 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 "Miree" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|