Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
cancel the loop
I have set up a loop to prepare selected reports for appropriate location(s).
When I have printed all of the reports I want and select "CANCEL", how do I set up the program to cancel the loop? ' Dim iResult As Integer Sheets("Mail List").Select Do iResult = InputBox("Please enter the Store Number:") Range("a15").Value = iResult ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True Loop End Sub Thanks in advance!!! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
cancel the loop
do
iresult = inputbox(...) if trim(iresult) = "" then exit do end if 'rest of stuff loop Terry wrote: I have set up a loop to prepare selected reports for appropriate location(s). When I have printed all of the reports I want and select "CANCEL", how do I set up the program to cancel the loop? ' Dim iResult As Integer Sheets("Mail List").Select Do iResult = InputBox("Please enter the Store Number:") Range("a15").Value = iResult ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True Loop End Sub Thanks in advance!!! -- Dave Peterson |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
cancel the loop
Try this
You can also use the test if the inputbox have a value if you want See two commented code lines in the macro Sub test() Dim iResult Sheets("Mail List").Select Do iResult = Application.InputBox("Please enter the Store Number:") If iResult = False Then Exit Do 'If iResult < "" Then Range("a15").Value = iResult ActiveWindow.SelectedSheets.PrintOut preview:=True 'End If Loop End Sub -- Regards Ron de Bruin http://www.rondebruin.nl "Terry" wrote in message ... I have set up a loop to prepare selected reports for appropriate location(s). When I have printed all of the reports I want and select "CANCEL", how do I set up the program to cancel the loop? ' Dim iResult As Integer Sheets("Mail List").Select Do iResult = InputBox("Please enter the Store Number:") Range("a15").Value = iResult ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True Loop End Sub Thanks in advance!!! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Workbook_BeforeClose(Cancel As Boolean) - Cancel won't work | Setting up and Configuration of Excel | |||
Disabling 'Cancel' option when saving work (Yes/No/Cancel) | Excel Programming | |||
Cancel button to cancel the whole macro | Excel Programming | |||
Cancel Macro is user selects 'cancel' at save menu | Excel Programming | |||
how to stop program with loop by click "Cancel" button | Excel Programming |