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 | MyExcelOnline

Exercise Workbook:

Print with a Narrow Margin Using Macros In Excel | MyExcelOnline

DOWNLOAD EXCEL WORKBOOK


This is our data table:

Print with a Narrow Margin Using Macros In Excel | MyExcelOnline

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 | MyExcelOnline

 

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 | MyExcelOnline

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

Print with a Narrow Margin Using Macros In Excel | MyExcelOnline

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

 Print with a Narrow Margin Using Macros In Excel | MyExcelOnline

 

How to Print with a Narrow Margin Using Macros In Excel

 

HELPFUL RESOURCE:

101 Macros Book

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

email

Pin on Pinterest

Share on Facebook

Tweet about this on Twitter

Share on LinkedIn