Not all recorded macros are re-usable. This print selection one is.
When you set your print area or use the Page Break Preview View, Excel will show you the page breaks on the grid. If this annoys or distracts you, here is how to remove them.
It’s a one-line macro that turns off the page breaks in the current sheet.
Sub TurnOffPageBreaks() ActiveSheet.DisplayPageBreaks = False End Sub
If you are new to macros then this blog post can take you through how to use them.
The above code can be copied and pasted into the code window.
If you want to turn page breaks off for all the sheets in the file use the code below.
Sub TurnOffAllPageBreaks() Dim ws For Each ws In Worksheets ws.DisplayPageBreaks = False Next ws End Sub
I hope these code snippets are useful.
Excel will automatically decrease the print zoom % to fit to one page, but it won’t increase the zoom % to fit to one page. E.g. if you want to print on A3 instead of A4. I had a request to do this, so I wrote a macro to do it.
When clearing page breaks in Excel VBA you need to be careful. There is one command that will clear page breaks but it will also affect other print settings.
In Excel you can us Save As to save a file as a pdf, but it isn’t quite as effective in Excel as it is for MS Word. Often you only want to save a single sheet or a few sheets to pdf. Try this.
Excel has a BeforePrint event which enables you run VBA code before a document is printed. This event can also be triggered by Print Preview. But not all Print Previews are the same.
If you want to place graphic objects on your sheet eg logos and checkboxes, but not have them print out, you need to change their properties.
In a recent training session I had a question about where the Print Selection option is in the new Excel versions.
It is easy to print things from Word. It is not so easy in Excel. Excel has this huge grid and if you don’t tell Excel otherwise, it will print everything on the sheet, whether you want it to or not.
Templates allow you to create blank sheets and blank workbooks that have customised formats as well as customised Page Setup settings, including headers and footers.
If I print emails I typically only want the first page. To do that in Outlook takes a few clicks each time.
If you need to print certain sheets in a file in one step you can set up a macro to do it automatically and flexibly.
Printing in Excel can be a tricky exercise. Both Word and PowerPoint basically don’t let you print outside the page, but each Excel sheet has a huge grid with over 17 billion individual cells. Printing large spreadsheets can be a challenge.