Macro Button--Print Page Setup


New Member
May 31, 2007
How can I create a macro button that will automatically set print "Page Setup" settings for me on the sheet I am in.

It needs to set setting in Page Setup to:

Sheet: check gridlines
Margin: Center Horizontally
Page: Landscape
Fit to 1 Page

Is it possible to have this macro built in to every excel workseet I open so I could have the print settings automatically at the click of a button?


MrExcel MVP
May 15, 2003
Welcome to the Board!

You can record a macro applying the Page Setup settings you want. Just make sure to scrub the code and remove any default settings that you haven't altered. You'll want to do this because Page Setup code is very slow, so anything you can remove from the process helps tremendously.

To make the code available to any open workbook you can put it in Personal.xls. If you don't have one, you can record a new macro and in the store macro in dialog, select Personal Macro Workbook. Then stop recording, and Personal.xls will have been created for you.

Hope that helps,


Jun 19, 2002
Perhaps if you mean in a single workbook then right click the Excel logo just to the left of File on the menu bar, select View Code and paste in

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
With Sh.PageSetup
    .PrintGridlines = True
    .CenterHorizontally = True
    .Orientation = xlLandscape
    .FitToPagesWide = 1
    .FitToPagesTall = 1
End With
End Sub

Forum statistics

Latest member

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...