Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 193
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Workbook_BeforeClose(Cancel As Boolean) - Cancel won't work gpmichal Setting up and Configuration of Excel 1 May 12th 09 02:33 AM
Disabling 'Cancel' option when saving work (Yes/No/Cancel) [email protected] Excel Programming 0 July 11th 06 09:28 PM
Cancel button to cancel the whole macro excelnut1954 Excel Programming 3 January 17th 06 08:27 PM
Cancel Macro is user selects 'cancel' at save menu Mark Excel Programming 1 April 6th 05 05:45 PM
how to stop program with loop by click "Cancel" button miao jie Excel Programming 2 December 16th 04 02:42 PM


All times are GMT +1. The time now is 08:56 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"