Sub topic 9
Gridlines, headings, comments, and error display
This chapter covers the Sheet Options and Sheet settings that decide which extra elements Excel prints along with your cell contents. It assumes you can open the Page Setup dialog, set a print area, and use Print Preview, as covered in earlier chapters.
What these options control
A worksheet on screen shows gridlines, row numbers, and column letters. Excel does not print any of them by default. Cell values, borders, fills, and shapes print. Comments and error values follow their own rules. You change all of this on the Sheet tab of the Page Setup dialog.
To open it, go to Page Layout, then select the small arrow at the bottom right of the Sheet Options group. You can also open Page Setup and choose the Sheet tab.
| Option | Default | Effect when changed |
|---|---|---|
| Gridlines | Off | Prints the light cell grid, including empty cells inside the print area |
| Row and column headings | Off | Prints the row numbers and column letters |
| Comments | None | Prints notes at the end of the sheet or as displayed on the sheet |
| Cell errors as | Displayed | Replaces error values with blank, `--`, or `#N/A` |
| Black and white | Off | Prints in black and white and ignores colors |
| Draft quality | Off | Skips gridlines and most graphics on some printers |
Gridlines and headings
Turn on gridlines when the data has no borders and readers need help following rows across the page. Gridlines print only for the cells inside the print area. If the print area covers A1:H60, the grid stops at column H and row 60.
If your table already has borders, leave gridlines off. Printing both makes the page look busy, and the two sets of lines do not always match in weight.
Row and column headings help when you share a printout and need to say "see cell D14". They also take up space, so check that your scaling still fits the page afterward.
Printing comments
Excel has two kinds of annotation. Notes are the older yellow boxes, and threaded comments are conversations tied to a cell. Notes can be printed as displayed or at the end of the sheet. Threaded comments print only at the end of the sheet, so choose that setting when you work with them.
The Comments list on the Sheet tab offers three choices:
- (None) prints no annotations.
- At end of sheet collects them on separate pages after the data, each with its cell address.
- As displayed on sheet prints notes where they appear on screen. This works only for notes you have chosen to show, and they can cover data.
Use At end of sheet for review copies. It keeps the data readable and lists every annotation in one place. Adding those pages changes the total page count, so a footer using &N will reflect it.
Hiding errors in output
Formulas can produce values such as #DIV/0!, #N/A, and #REF!. These look careless in a report. The Cell errors as list on the Sheet tab replaces them only on paper:
- displayed prints the error as is.
- <blank> prints an empty cell.
- -- prints two dashes.
- #N/A prints
#N/Afor every error type.
This setting hides symptoms and does not fix the cause. A blank cell where a lookup failed can look like a legitimate empty value. Review the errors on screen first, and use this option only when you understand why each one appears. For errors you want to handle in the data itself, wrap the formula, for example =IFERROR(B2/C2, "").
Applying the settings with VBA
You can set the same options in a macro. The values below are those for the Sheet tab.
Sub SetupSheetOptions()
With ActiveSheet.PageSetup
.PrintGridlines = True
.PrintHeadings = True
.PrintComments = xlPrintSheetEnd
.PrintErrors = xlPrintErrorsBlank
.BlackAndWhite = False
End With
End SubxlPrintSheetEnd matches "At end of sheet". xlPrintInPlace matches "As displayed on sheet", and xlPrintNoComments matches "(None)". For errors, the other constants are xlPrintErrorsDash, xlPrintErrorsNA, and xlPrintErrorsDisplayed.
Checking the result
Open Print Preview after changing any of these options. Comments printed at the end of the sheet appear as extra pages, and headings can push content onto a new page. Because PDF export uses the same page setup, what you see in preview is what the PDF contains.
Exercise
A colleague's PDF shows #N/A in several cells, and you want them blank in the output without changing any formulas. Which setting do you change, where is it, and what is the risk?
Show answer
On the Sheet tab of Page Setup, set Cell errors as to <blank>. In VBA this is .PrintErrors = xlPrintErrorsBlank. The risk is that real problems are hidden, so a failed lookup looks like an empty value. Review the errors on screen first.
Exercise
You print a sheet with threaded comments and choose "As displayed on sheet". The comments are missing. What should you choose instead?
Show answer
Choose At end of sheet. Threaded comments print only at the end of the sheet, so the "As displayed" option does not print them.