Printing a range using a written macro

nigelandrewfoster

Well-known Member
Joined
May 27, 2009
Messages
747
When I replace the recorded code for reliably printing a particular range with this simplified version, all manner of strange results can occur, usually small printouts or partial printouts. Am I missing something?
Code:
Sub DAILY_TASKS()
    With ActiveSheet
        .PageSetup.PrintArea = "$A$1:$u$50"
        .PrintOut Copies:=1, Collate:=True
    End With
End Sub
Thanks!
Nigel
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Is the range a fixed range or selected cells then print them?

2 samples below:

Sub print1()
Range("A1:B25").PrintOut
End Sub
Sub print2()
Selection.PrintOut
End Sub
 
Upvote 0
Fixed range only. Beautifully simple solution, my friend!
One problem: it gave me a printout, but it's tiny. I want it to fill the page. When I go into print preview it does just that, but printout is approx 25% the size it should be.
 
Upvote 0
1. If you manually go in to Page Setup, on the Page tab in the Scaling section, what settings do you find?

2. Should A1:U50 fit on a single page? If not do you just want it to use as many pages as it needs?
 
Upvote 0
What about changing the font size and autofit column before printing then? What is on the current page setup settings?

Sub print1()
Range("J1:N10").Font.Size = 20
Columns("J:N").AutoFit
Range("J1:N10").PrintPreview
End Sub
 
Upvote 0
First, Page Tab info: Scaling says Adjust to 100% normal size, Fit to 1 pages wide by 1 tall. Mini printout when former radial button selected, 4-page printout(!) when latter selected.
Second, yes, should fit nicely on a single page. And does do what I want when I manually click "set print area." But I want a simplest possible macro to do the same.
 
Upvote 0
I wouldn't fiddle with your font, column widths etc, but rather just add a little to your original code. Try this:

<font face=Courier New><br><SPAN style="color:#00007F">Sub</SPAN> DAILY_TASKS()<br>    <SPAN style="color:#00007F">With</SPAN> ActiveSheet<br>        <SPAN style="color:#00007F">With</SPAN> .PageSetup<br>            .PrintArea = "$A$1:$U$50"<br>            .Zoom = <SPAN style="color:#00007F">False</SPAN><br>            .FitToPagesWide = 1<br>            .FitToPagesTall = 1<br>        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>        .PrintOut Copies:=1, Collate:=<SPAN style="color:#00007F">True</SPAN><br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,813
Members
452,945
Latest member
Bib195

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