How to Remove Margins in Excel: 4 Methods

Margin settings in Excel can sometimes affect the layout and presentation of your worksheet. Excel provides the option to adjust and remove these margins. Adjusting and modifying margins in Excel can significantly improve the visual appeal and usability of your spreadsheets.

In this article, you will explore various techniques to affect margins and the reasons behind removing them altogether.

Reasons to Remove Excel Margins in Excel

While margins play a crucial role in designing spreadsheets, there are situations you need to remove Excel margins becomes necessary. Please take a look at some of the reasons to remove margins in Excel.

  1. By adjusting margins, you can maximize the space available for data entry and analysis.
  2. Selecting Narrow margins can help eliminate unnecessary blank spaces around your content, allowing for a cleaner and more focused visual presentation. This becomes particularly significant when creating charts or graphs.
  3. You may want to print your spreadsheet without any margins, enabling a transition from screen to paper.

Type of Margins in Excel

There are 4 different margins Normal, Wide, Narrow, Last Custom Setting, and Custom Options in Excel.

Normal is the default margin of your Excel workbook. The standard spacing is used for the headers, footers, top, bottom, left, and right corners of the page.

A little more area is taken up by the Wide type. You can use this Wide margin option when your data is small, and you wish to present them more effectively.

The Narrow margin takes up some space away from the page border. Usually used when you want to fit a lot of text onto one page and the margin is large.

Occasionally, you may need to separately adjust the margins. You can use the Custom Margin option in these circumstances.

Last Custom Setting displays the additional margin you previously defined and saved to the sheet.

Access the Page Setup Options and Remove the Margins

You will need to access the Page Setup options to remove margins in Excel. It is one of the well-known ways to change the page layout in Excel.

Please follow these steps to access the page setup in Excel.

  1. Open your Excel workbook.
  2. Click the Page Layout tab in the Excel ribbon.
  3. Click the Page Setup group.

A dialog box will appear, presenting various customization options for your worksheet.

Now, you have accessed the Page Setup options. Excel allows you to modify both the page margins and the header/footer margins.

Adjust Page Margins

Page margins define the blank spaces surrounding the actual content on a printed page. You can control how close your data appears to the page edges by adjusting these settings.

Steps to adjust the Page margins:

  1. Navigate to the Margins tab in the Page Setup dialog box.
  2. You will see four inputs for top, bottom, left, and right margins. Enter the zero into these inputs to remove the margins accordingly.

Adjust Header/Footer Margins

Header and footer margins refer to the space allocated for headers and footers in your worksheet. Header and Footer areas allow you to include essential information such as page numbers, titles, or company logos.

Enter the zero into the corresponding boxes to modify the header/footer margins in the Margins tab in the Page Setup dialog box.

It is important to preview the changes before finalizing them after adjusting the margins. Excel Print preview allows you to visualize the impact of your modifications.

Please note that the margin that you choose on the Page Layout tab only affects the sheet that is currently open. Hold down the Ctrl or Shift keys to select other sheets in your workbook.

Remove the Margins with VBA

In this section, you will explore the use of VBA code to remove margins in Excel. You can use this procedure to remove margins if you have multiple sheets in your workbook or have to do multiple workbooks.

Sub removeMargins()

Dim sh As Worksheet

' Loop through each sheet in the active worksbook

For Each sh In ActiveWorkbook.Sheets

    ' Reset Left, Right, Top, Bottom, Header and Footer Margins

    With sh.PageSetup

            .LeftMargin = Application.InchesToPoints(0)

            .RightMargin = Application.InchesToPoints(0)

            .TopMargin = Application.InchesToPoints(0)

            .BottomMargin = Application.InchesToPoints(0)

            .HeaderMargin = Application.InchesToPoints(0)

            .FooterMargin = Application.InchesToPoints(0)

    End With

Next

End Sub

Press Alt + F11, the keyboard shortcut to open the Visual Basic window. In the VBE, Select Module in the Insert tab then copy and paste the above VBA code into the window.

The above code is to set the left, right, top, bottom, header and footer margins to zero using VBA. The code uses a For Each loop to iterate through each worksheet object in the Worksheets collection of the active workbook.

Inside the loop, the code accesses the PageSetup property and then assigns the value of the Application.InchesToPoints(0) to all the respective margins of the PageSetup object.  It converts zero inches to points and sets the margins accordingly.

To Run the removeMargins macro in Excel

Press Alt + F8, the keyboard shortcut to open the Macro dialog box.

Choose the removeMargins Macro in the macro list and then Press Run.

Remove the Margins with OS

In Office Scripts, you can use the PageLayout object to access and update the properties of the worksheet, such as margins, orientation, paper size, header and footer.

function main(workbook: ExcelScript.Workbook) {

  // Go to each worksheet so the print settings are consistent.

  workbook.getWorksheets().forEach((sheet) => {

    // Get sheet Page Layout

    const pgeLayout: ExcelScript.PageLayout = sheet.getPageLayout();

    // Reset 0 to Left, Right, Top, Bottom, Header and Footer Margins

    pgeLayout.setLeftMargin(0)

    pgeLayout.setRightMargin(0)

    pgeLayout.setTopMargin(0)

    pgeLayout.setBottomMargin(0)

    pgeLayout.setHeaderMargin(0)

    pgeLayout.setFooterMargin(0)

  });

}

The above code is to set the margins left, right, top, bottom, header and footer. The forEach loop to iterate through each worksheet in the Worksheets collection of the active workbook.

The code use sheet.getPageLayout() function to access the PageLayout property then sets zero to all the margins.   

Follow the below steps to execute the Remove Margins Office scripts in your Excel

Go to the Automate menu.

Select the Remove Margins Script – to open the Code editor on the right side of the Excel window.

Press Run 

Remove the Page Break dotted line in Excel

The margin dotted lines help your users visualize page breaks.  But in some situations, these lines can be uncomfortable and not needed. In this section, you will learn to use the Show Page Break option to remove these margins.

Please follow the steps to remove the Page Break dotted line in Excel.

  1. Go to the File tab.
  2. Select the Options from the bottom left corner of the window.

Alt + F + T is a keyboard shortcut to open the Excel Options dialog box

  1. Select the Advanced option from the Excel Options window.
  2. Scroll down to find Display options for this worksheet.
  3. uncheck the Show page breaks option.

Alternatively, you can press Alt + K to select the Show page breaks check box and then uncheck in the Excel Options window.

You can use the below VBA code If you need to uncheck the Show page break in your automation. The code works as a toggle button. It sets the DisplayPageBreaks property to all the worksheets in the active workbook.

Sub TogglePageBreak()

' Loop through each sheet in the active worksbook
For Each sh In ActiveWorkbook.Sheets

    ' Set boolean value to DisplayPageBreaks property
    ActiveSheet.DisplayPageBreaks = Not ActiveSheet.DisplayPageBreaks

Next

End Sub

Conclusion

Setting margins when you print sheets to paper is crucial to the aesthetics of the page and data. Data will be split and sent to the next page when the margins are too wide. Margins that are too small make the data unpleasant and cluttered. Therefore, when printing, it is crucial to check, adjust and change the margins according to the data.

You learned how to remove and adjust the margins in Excel. Depending on your preferences, you have the option to modify and specify the margins or use the preset ones.

You explored a few methods to alter the page layout to suit your needs. It enables you to present your data in an understandable and well-organized way.

If you use any alternative ways to adjust the margins in Excel. Please let me know in the comments section!

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *