Page 1 of 1

Printout

Posted: Thu May 14, 2020 6:51 pm
by sna
Hi Dear,
I got this code from my friend.
Those code is use print from selected any range in a sheet thru inputbox but it is no luck.
Sub PrintIt()
Dim rRange As Range
Set rRange=Application.InputBox("Please select the range",Type:=8)
With Sheets(Application.InputBox("Input Sheet Name"))
.PageSetup.PrintArea=rRange.Address
.PrintOut Copies:=Inputbox("Number of copies:"), Collate:=True
End With
End Sub


Best wishes

Re: Printout

Posted: Thu May 14, 2020 8:44 pm
by snasui
:D Your code should be show with code style, begin with [code] and end with [/code] like show as below.

Code: Select all

Sub PrintIt()
Dim rRange As Range
Set rRange=Application.InputBox("Please select the range",Type:=8)
With Sheets(Application.InputBox("Input Sheet Name"))
.PageSetup.PrintArea=rRange.Address
.PrintOut Copies:=Inputbox("Number of copies:"), Collate:=True
End With
End Sub
I have tested this code and it worked properly not show any problem.

Re: Printout

Posted: Thu May 14, 2020 8:59 pm
by sna
Hi Dear
This code seems conflict .how do I edit code to
select sheet first then range for printing?

Best wishes

Re: Printout

Posted: Fri May 15, 2020 7:11 am
by snasui
:D This statement show input box for fill in with your target sheet name for print.

Code: Select all

With Sheets(Application.InputBox("Input Sheet Name"))
...Other code
Please adjust for your task first and if it has any problem please post here with adjusted code.