Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
raw raw is offline
external usenet poster
 
Posts: 1
Default Code error with input box


Hi Guys

Here is my code 4 a print box (how many copies would you like)

Private Sub CommandButton1_Click()
Dim ws As Worksheet
Dim no_of_copies As Integer

Select Case True
Case OptionButton1
Set ws = Sheets("verticalordersheet")
Case OptionButton2
Set ws = Sheets("verticalvanesordersheet")
End Select

no_of_copies = Application.InputBox("How many copies do you wish t
print?", , 1)

ws.PrintOut copies:=no_of_copies, Collate:=True


Close

End Sub

But i get 2 errors

1. is "Run-time error 91" This happens when you do not select a optio
button

2. is "Run-time error 1004" This happens when you press the cance
button

Can you help

Thank

--
ra
-----------------------------------------------------------------------
raw's Profile: http://www.excelforum.com/member.php...fo&userid=2831
View this thread: http://www.excelforum.com/showthread.php?threadid=47898

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Code error with input box

Private Sub CommandButton1_Click()
Dim ws As Worksheet
Dim no_of_copies As Integer

Select Case True
Case OptionButton1.Value
Set ws = Sheets("verticalordersheet")
Case OptionButton2.Value
Set ws = Sheets("verticalvanesordersheet")
Case Else
Exit sub
End Select

no_of_copies = Application.InputBox("How many copies do you wish to
print?", , 1)
if no_of_Copies = 0 then exit sub
ws.PrintOut copies:=no_of_copies, Collate:=True

' not sure what close is supposed to be
Close

End Sub

--
Regards,
Tom Ogilvy


"raw" wrote in message
...

Hi Guys

Here is my code 4 a print box (how many copies would you like)

Private Sub CommandButton1_Click()
Dim ws As Worksheet
Dim no_of_copies As Integer

Select Case True
Case OptionButton1
Set ws = Sheets("verticalordersheet")
Case OptionButton2
Set ws = Sheets("verticalvanesordersheet")
End Select

no_of_copies = Application.InputBox("How many copies do you wish to
print?", , 1)

ws.PrintOut copies:=no_of_copies, Collate:=True


Close

End Sub

But i get 2 errors

1. is "Run-time error 91" This happens when you do not select a option
button

2. is "Run-time error 1004" This happens when you press the cancel
button

Can you help

Thanks


--
raw
------------------------------------------------------------------------
raw's Profile:

http://www.excelforum.com/member.php...o&userid=28312
View this thread: http://www.excelforum.com/showthread...hreadid=478987



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
Pause code, wait for input, no input received, carry on with the code [email protected] Excel Programming 1 September 29th 05 12:19 PM
Input Box Question with Code Bob Phillips[_6_] Excel Programming 0 August 16th 04 07:29 PM
Input Box Code Please Help!! Struggling Hard!! Excel Programming 3 July 30th 04 12:29 AM
Code for Input Box Laura C Excel Programming 4 June 29th 04 05:27 PM
CODE to select range based on User Input or Value of Input Field Sandi Gauthier Excel Programming 4 December 8th 03 03:22 PM


All times are GMT +1. The time now is 09:04 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"