Sub topic 9
Gridlines, headings, comments, and error display
This chapter covers four settings on the Sheet tab of the Page Setup dialog. They control whether gridlines print, whether row and column headings print, how comments and notes print, and how cell errors appear on paper. All four apply to PDF export as well as to printing. By the end you should be able to decide which of them a given printout needs, set them by hand or with VBA, and avoid the common surprises.
The chapter assumes you can reach the Page Setup dialog and know how to set a print area, as covered in earlier chapters. It also assumes you can use Print Preview to check a layout.
Where the settings live
You can reach these options in two places.
- The Page Layout tab has a Sheet Options group. It has Gridlines and Headings columns, each with View and Print checkboxes.
- The Sheet tab of the Page Setup dialog has every option in this chapter. To open it, select the small arrow at the corner of the Sheet Options group, or the one in the Page Setup group, and then choose the Sheet tab.
The Sheet tab is the only place that offers the comment and error options, so most of the work happens there.
| Option | Sheet tab location | VBA property |
|---|---|---|
| Gridlines | Print: Gridlines | `PrintGridlines` |
| Row and column headings | Print: Row and column headings | `PrintHeadings` |
| Comments | Comments: dropdown | `PrintComments` |
| Cell errors | Cell errors as: dropdown | `PrintErrors` |
| Black and white | Print: Black and white | `BlackAndWhite` |
| Draft quality | Print: Draft quality | `Draft` |
View versus Print
The View and Print checkboxes are independent. The View checkbox changes only what you see on screen. Hiding gridlines on screen does not stop them from printing, and printing gridlines does not turn them on in the window.
- A clean-looking dashboard often has View gridlines off and Print gridlines off. Both are normally what you want.
- A data dump you want to read on paper may have View gridlines off but Print gridlines on.
If a printout shows lines you thought you had removed, check the Print checkbox and not the View one.
Printing gridlines
Gridlines are the faint lines between cells. By default they do not print. Turn on Print: Gridlines when the data has no borders and you want a grid on paper.
Keep these behaviors in mind:
- Gridlines print only inside the printed range. If you have set a print area, gridlines cover that area. Without one, they cover the used range of the sheet.
- Cells with a fill color show no gridlines. A white or colored fill hides the gridline behind it, on screen and on paper. Cell borders are not affected by this, so use borders when you need lines that always print.
- Borders print whatever this option is set to. Gridlines are a convenience. When the lines are part of the design, such as a table or an invoice, apply real borders.
- Draft quality removes gridlines. If you tick Draft quality, Excel skips most graphics and gridlines to print faster. Leave it off for any document you plan to share.
Printing row and column headings
Headings are the row numbers down the left side and the column letters across the top. Turning on Print: Row and column headings puts them on the page.
This is useful in a few cases:
- Reviewers who discuss a printout by cell address, such as "check D14".
- Audit copies of a model, where a formula in a printed cell refers to other cells.
- Documentation pages that show where data sits on the sheet.
Headings print on every page, in the position they hold on the sheet. If you set repeating title rows, the repeated rows keep their original row numbers. Leave headings off for anything meant for a client, because they make a printout look like a spreadsheet and not a report.
Printing comments and notes
Current Microsoft 365 versions have two kinds of annotation:
- Notes are the older yellow boxes, once called comments. A red triangle marks the cell.
- Comments are the newer threaded conversations, with replies and names. A purple marker flags the cell.
The Comments dropdown has three choices.
| Choice | Result |
|---|---|
| (None) | No annotations print. This is the default. |
| At end of sheet | Annotations print on separate pages after the sheet, each with its cell address. |
| As displayed on sheet | Annotations print where they appear on screen. |
Some points to know:
- At end of sheet is the safest choice. It never covers data and lists every annotation with its cell address, such as
Cell: C7. - As displayed on sheet only prints what is visible. For notes, make them visible first. On the Review tab, use Notes, then Show All Notes. A hidden note does not print in this mode.
- Placement is not guaranteed. A note box can sit on top of data or run off the edge of the print area. Preview the result. If a box covers important cells, drag it to an empty area or switch to At end of sheet.
- Threaded comments are best printed at the end of the sheet. They are conversations and do not have a place on the sheet face. Use that option and check the preview, because behavior can differ between Excel versions.
- The extra pages count toward your total. If you use a page number such as
Page &P of &N, the comment pages are included in&N. A six-page sheet with two pages of notes shows "of 8".
Controlling how cell errors print
A formula can return an error such as #DIV/0!, #N/A, #REF!, #VALUE!, #NAME?, #NULL!, or #NUM!. On paper these look like faults even when the cause is harmless, such as an average over an empty month.
The Cell errors as dropdown changes how they are printed:
- displayed prints the error as it appears on screen. This is the default.
- \<blank\> prints an empty cell.
- -- prints two dashes.
- #N/A prints
#N/Ain place of any error.
Things to remember:
- The cell is unchanged. Only the printed output changes. The error still sits in the cell, and formulas that depend on it still fail.
- Blank hides real problems. A
#REF!from a deleted column prints as an empty cell, so a broken report can look finished. Use blank or dashes only on sheets whose errors you understand. - Fixing the formula is the better long-term answer.
IFERRORorIFNAin the formula handles the error where it happens and gives the same result on screen and on paper.
=IFERROR(B2/C2, "")The print option is a quick cosmetic fix. It is a good choice when you cannot change the formulas, for example in a workbook someone else maintains. It is a poor choice as the permanent way to hide errors.
Black and white and draft quality
Two neighboring checkboxes on the Sheet tab belong to this group of options.
- Black and white prints all colors as black and white, with no shades of gray. Use it for printers that turn colored fills into muddy gray, or to save toner. It does not change the sheet on screen.
- Draft quality prints faster at lower quality. It drops most graphics and gridlines, as described above. Printers differ in how much they reduce, and some ignore it.
Leave both off unless you have a clear reason.
Choosing options: a quick decision flow
The diagram shows how to choose the options for a typical printout.
Applying the options to several sheets
Page Setup changes apply to the active sheet only. To change several sheets at once, group them:
- Select the first sheet tab.
- Hold Ctrl and select the other tabs. Or hold Shift and select the last tab for a continuous range.
- Open the Page Setup dialog and make your changes. The title bar shows [Group].
- Right-click a tab and choose Ungroup Sheets.
Forgetting to ungroup is a common mistake. While sheets are grouped, anything you type on one sheet is written to all of them.
Setting the options with VBA
The properties in the table at the start of this chapter let you apply the same choices to every sheet in a workbook.
Sub ApplySheetPrintOptions()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
With ws.PageSetup
.PrintGridlines = False
.PrintHeadings = False
.PrintComments = xlPrintSheetEnd
.PrintErrors = xlPrintErrorsBlank
.BlackAndWhite = False
.Draft = False
End With
Next ws
End SubThese constants are available for the two dropdown settings:
| Property | Constants |
|---|---|
| `PrintComments` | `xlPrintNoComments`, `xlPrintSheetEnd`, `xlPrintInPlace` |
| `PrintErrors` | `xlPrintErrorsDisplayed`, `xlPrintErrorsBlank`, `xlPrintErrorsDash`, `xlPrintErrorsNA` |
Setting PageSetup properties can be slow on workbooks with many sheets, because Excel talks to the printer driver for each change. It also fails with an error when no printer is installed. If macros run slowly, set Application.PrintCommunication = False before the loop and True after it. That is optional, and the loop above works without it.
Common problems
- Gridlines do not appear on the printout. Check that Print: Gridlines is on, that the cells have no fill color, and that Draft quality is off.
- Gridlines stop short of the data. They print only inside the print area or used range. Extend the print area to include the empty cells.
- Notes are missing from the PDF. Notes need Comments set to At end of sheet or As displayed on sheet. For the second option, they must also be visible.
- A note covers a table. Switch to At end of sheet, or move the note box.
- Errors still print after setting blank. The setting is saved per sheet. Check that you changed the correct sheet, or that no other sheets were left out of a group.
- Extra pages appear at the end. These are usually the comment pages. Set Comments to (None) if you do not want them.
Exercise
A finance sheet prints cleanly on screen, but the PDF has a "#DIV/0!" in a total row, and the reviewer also wants each printed page to show which cell holds each remark. You are not allowed to change the formulas. Which two Sheet tab settings do you change, and what is one risk of the first one?
Show answer
Set "Cell errors as" to <blank> (or --) to hide the error on paper, and set Comments to "At end of sheet" so each remark prints with its cell address. The risk of the error setting is that real problems such as #REF! also print as blank, so a broken report can look complete. The cells themselves still contain the errors.
Exercise
Write the VBA statements that make the active sheet print gridlines and row and column headings, print notes at the end of the sheet, and show errors as dashes.
Show answer
With ActiveSheet.PageSetup .PrintGridlines = True .PrintHeadings = True .PrintComments = xlPrintSheetEnd .PrintErrors = xlPrintErrorsDash End With
Exercise
You turn off View gridlines on the Page Layout tab, but the printout still shows gridlines. Why, and how do you fix it?
Show answer
The View and Print checkboxes are separate. View affects only the screen. Clear the Print checkbox under Gridlines (or clear Print: Gridlines on the Sheet tab of Page Setup). If the lines are meant to stay, apply borders instead.