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

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
18,075
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
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

josmarfieror

New Member
Joined
Dec 4, 2016
Messages
4
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

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
21,608
Office Version
  1. 365
  2. 2019
  3. 2013
  4. 2007
Platform
  1. Windows
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

josmarfieror

New Member
Joined
Dec 4, 2016
Messages
4
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,191,718
Messages
5,988,275
Members
440,146
Latest member
rgomes8

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
Top