first go around inputbox

C

Curt

Found out when testing I didn't get all needed. What I've got works unless
you hit cancel or enter 0 Following is what I've done seems all I find goes
to a greater extent than I need. All help greatly appreciated.
Following is what iI've got
Thanks to All

With Sheets("Check_In")
Sheets("Check_In").Select
pCnt = InputBox("How Many Copies") '2
ActiveWindow.SelectedSheets.PrintOut Copies:=Val(pCnt), Collate:=True '2
.pagesetup.PrintArea = "A2:D" & Cells(Rows.Count, "B").End(xlUp).Row
End With
 
J

JLatham

Try modifying your code to add this stuff (I'm showing complete routine but
it doesn't include your With/End With and .Select and Printout statements,
which you need to add back in).

Sub TestInputBox()
Dim pCnt As Integer

On Error Resume Next
pCnt = InputBox("Enter # of copies", , 0)
If Err <> 0 Then
'they hit [Cancel]
Err.Clear
On Error GoTo 0
Exit Sub
End If
On Error GoTo 0
'didn't hit [Cancel] but pCnt may be zero
If pCnt > 0 Then
'do your printout command here
End If

End Sub
 
B

Bob Phillips

pCnt = InputBox("How Many Copies") '2
If pCnt <> "" Then

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
J

Jim Cone

pCnt = Val(InputBox("How Many Copies"))
If pCnt < 1 or pCnt > 9 Then Exit Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)


"Curt" <[email protected]>
wrote in message
Found out when testing I didn't get all needed. What I've got works unless
you hit cancel or enter 0 Following is what I've done seems all I find goes
to a greater extent than I need. All help greatly appreciated.
Following is what iI've got
Thanks to All

With Sheets("Check_In")
Sheets("Check_In").Select
pCnt = InputBox("How Many Copies") '2
ActiveWindow.SelectedSheets.PrintOut Copies:=Val(pCnt), Collate:=True '2
.pagesetup.PrintArea = "A2:D" & Cells(Rows.Count, "B").End(xlUp).Row
End With
 
J

Jim Thomlinson

For that I like an Application.InputBox with Type set to 1 to validate for
numbers. Something like this...

dim pCnt as Long
pCnt = Appliation.InputBox("How Many Copies", Type:=1)
If pCnt < 1 or pCnt > 9 Then Exit Sub
ActiveWindow.SelectedSheets.PrintOut Copies:=pCnt, Collate:=True '2
.pagesetup.PrintArea = "A2:D" & Cells(Rows.Count, "B").End(xlUp).Row
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top