Printing Twice

josmarfieror

New Member
Joined
Dec 4, 2016
Messages
4
Dear MrExcel,

Please help me in executing my code below. I got a problem because they were printed TWICE. It's a waste of Paper and ink on my part.

Sub GenericInputbox()
Dim SprNum As String
SprNum = Inputbox("Enter the row number")
Range("M10").Value = SprNum
'to print the output
If Application.Dialogs(xlDialogPrint).Show = True Then
Application.ActiveSheet.PrintOut Copies:=1, Collate:=True
End If
End Sub

Thanks,
Josmar
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Does this work for you?

Sub GenericInputbox()
Dim SprNum As String
SprNum = Inputbox("Enter the row number")
Range("M10").Value = SprNum
'to print the output
Application.ActiveSheet.PrintOut Copies:=1, Collate:=True
End Sub
 
Upvote 0
Does this work for you?

Sub GenericInputbox()
Dim SprNum As String
SprNum = Inputbox("Enter the row number")
Range("M10").Value = SprNum
'to print the output
Application.ActiveSheet.PrintOut Copies:=1, Collate:=True
End Sub

HiJoe,

Thank you so much! I feel sad hearing about your state now. Yes, I did that code. However, what if in case I wanted to abort the printing because i got mistake. How would it be?

Thanks,
josmarfieror
 
Upvote 0
Maybe this if the Input box is blank
Code:
Sub GenericInputbox()
Dim SprNum As String
SprNum = InputBox("Enter the row number")
If SprNum = "" Then Exit Sub
Range("M10").Value = SprNum
'to print the output
Application.ActiveSheet.PrintOut Copies:=1, Collate:=True
End Sub
 
Upvote 0
Maybe this if the Input box is blank
Code:
Sub GenericInputbox()
Dim SprNum As String
SprNum = InputBox("Enter the row number")
If SprNum = "" Then Exit Sub
Range("M10").Value = SprNum
'to print the output
Application.ActiveSheet.PrintOut Copies:=1, Collate:=True
End Sub


DearMichaelM
It works. However, when I tried to protect the sheet, the a debug "400" has shwon.

Thanks,
Josmar
 
Upvote 0

Forum statistics

Threads
1,213,527
Messages
6,114,150
Members
448,552
Latest member
WORKINGWITHNOLEADER

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top