Pinterest Pixel

Print with a Narrow Margin Using Macros In Excel

In Excel we can opt to print out with very narrow margins through its interface. We can... read more

Download Excel Workbook
Bryan
Posted on

Overview

In Excel we can opt to print out with very narrow margins through its interface. We can do the same thing with Excel Macros, you can print with a narrow margin, or even customize the margin values so that it will be constant every time!

Make sure your Excel has the Developer Tab enabled following this tutorial.

I explain how you can do this below step by step!

What does it do?

Prints out with narrow margins then shows the print dialog

Copy Source Code:


Sub PrintWithNarrowMargin()

'Set the Margins to be narrow and print it out
With ActiveSheet.PageSetup
.HeaderMargin= Application.InchesToPoints(0.3)
.FooterMargin= Application.InchesToPoints(0.3)
.LeftMargin= Application.InchesToPoints(0.25)
.RightMargin= Application.InchesToPoints(0.25)
.TopMargin= Application.InchesToPoints(0.75)
.BottomMargin= Application.InchesToPoints(0.75)
End With

Application.Dialogs(xlDialogPrint).Show

End Sub

Final Result: 

Print with a Narrow Margin Using Macros In Excel

Exercise Workbook:

Print with a Narrow Margin Using Macros In Excel | MyExcelOnline

Download excel workbookPrint-with-a-Narrow-Margin.xlsm


This is our data table:

Print with a Narrow Margin Using Macros In Excel

STEP 1: Go to Developer > Code > Visual Basic

Print with a Narrow Margin Using Macros In Excel | MyExcelOnline

 

STEP 2: Paste in your code and Select Save. Close the window afterwards.

Print with a Narrow Margin Using Macros In Excel

 

STEP 3: Let us test it out!

Open the sheet containing the data. Go to Developer > Code > Macros

Print with a Narrow Margin Using Macros In Excel | MyExcelOnline

 

Make sure your macro is selected. Click Run.

Print with a Narrow Margin Using Macros In Excel

The Print Dialog is shown. Click OK once settings are good.

Print with a Narrow Margin Using Macros In Excel

With just one click, you have now printed out with narrow margins!

 Print with a Narrow Margin Using Macros In Excel

 

How to Print with a Narrow Margin Using Macros In Excel

 

101 Macros Book

If you like this Excel tip, please share itEmail this to someone

email

Pin on Pinterest

Pinterest

Share on Facebook

Facebook

Tweet about this on Twitter

Twitter

Share on LinkedIn

Linkedin

Print with a Narrow Margin Using Macros In Excel | MyExcelOnline
Bryan

Bryan is a best-selling book author of the 101 Excel Series paperback books.

Get Video Training

Advance your Microsoft Excel & Office Skills with the MyExcelOnline Academy!

Dramatically Reduce Repetition, Stress, and Overtime!
Exponentially Increase Your Chances of a Promotion, Pay Raise or New Job!

Learn in as little as 5 minutes a day or on your schedule.

Learn More!