Sub topic 13
Arranging Controls in an Interactive Report
This chapter assumes you can insert slicers and timelines, connect them to several PivotTables through Report Connections, and change a slicer's size, columns, and style. Here you will combine those pieces into one sheet that someone else can use without help.
What a good layout does
A slicer or timeline floats above the cells like a shape. Excel does not place it for you, so a sheet with several controls can easily turn into a pile of overlapping boxes. A good layout does three things:
- It lets the reader find every control without scrolling.
- It shows which controls affect which numbers.
- It keeps the controls usable when the data changes size.
Most layouts follow the same pattern: controls on one edge, summary figures and charts in the middle, and detail tables below or on another sheet.
Plan the sheet before placing controls
Decide where the PivotTables will live. Many report builders keep them on a separate sheet, often called Data or Calc, and place only PivotCharts and controls on the dashboard sheet. A slicer connected through Report Connections works across sheets, so the controls do not have to sit next to the PivotTables they filter.
Putting PivotTables on the dashboard sheet has a cost. When a PivotTable grows after a filter change, it can push into cells that hold other content, or Excel can refuse to refresh it. If you must keep PivotTables on the dashboard sheet, leave empty space below and to the right of each one.
Then choose the control band position:
| Position | Works well when | Watch out for |
|---|---|---|
| Top band | You have a timeline plus two to four slicers | Uses vertical space that charts could use |
| Left column | You have many slicers with long item lists | Narrows the area for charts |
| Right column | Readers scan left to right and want results first | Controls can fall off screen on small displays |
A timeline is wide and short, so it fits a top band. Tall slicers with many items fit a left column.
Align and size controls consistently
Uneven controls look unfinished and make the report harder to scan. Excel has tools for this on the contextual Slicer or Timeline tab.
- Select the first control. Hold Ctrl and click each additional control. All of them must be selected for the alignment commands to work.
- On the Slicer tab (or Timeline tab), use Align in the Arrange group. Choose Align Top to line up a row, or Align Left to line up a column.
- Use Distribute Horizontally or Distribute Vertically so the gaps between three or more controls are equal.
- In the Size group, type the same value into Height or Width for controls that should match. The values apply to every selected control.
While you drag a single control, hold Alt. The edges then snap to the cell gridlines, which makes it easy to line controls up with chart edges that also snap to cells.
Rename controls so you can find them
Open the Selection Pane from the Arrange group (or Home > Find & Select > Selection Pane). It lists every shape on the sheet, including slicers, timelines, and charts. Each slicer has a default name such as "Region" or "Region 1", which becomes confusing when two sheets each have a Region slicer. Double-click a name in the pane and give it a clear one, such as "Region filter". The Selection Pane also lets you:
- Select a control that is hidden behind a chart.
- Hide a control temporarily with the eye icon, without deleting it.
- Change the stacking order, so a control sits in front of a chart background.
Renaming in the Selection Pane changes the shape name. It does not change the slicer cache name, which VBA code uses (for example, Slicer_Region). The two names are separate.
Make several controls readable
The slicer settings you already know matter more once controls sit next to each other.
- Header caption. Change each caption to say what the reader is choosing, such as "Choose a region". A control with no header takes less space but gives no clue about what it filters.
- Columns. A slicer for a field with 12 items can become a compact block of 3 or 4 columns instead of one long list. Match the control's width to the number of columns so button text is not cut off.
- Style. Pick one slicer style and one timeline style for the whole report. Use a strong colour only for the control that matters most. If every control is bright, none of them stands out.
- Colour meaning. In the default styles, a selected item is coloured and an unselected item is grey. Keep a style where that difference is clear, because readers rely on it to tell which items are active.
Control how controls behave when cells change
A slicer is a shape, and shapes have a placement rule. Right-click a control, choose Size and Properties (or Format Slicer), and open Properties. You will find three options:
- Move and size with cells. The control stretches when you resize rows or columns underneath it.
- Move but don't size with cells. The control moves with its cells but keeps its size.
- Don't move or size with cells. The control stays where it is.
For a dashboard, "Move but don't size with cells" is usually the safest choice. If a reader hides a column or autofits a row, the controls keep their shape. With "Move and size with cells", a hidden column can squash a slicer until its buttons are unreadable.
Keep controls visible while scrolling
Slicers do not scroll differently from other shapes. They move with the sheet. To keep a control band in view, put it in the top rows and use View > Freeze Panes > Freeze Top Rows, or select the row below the band and choose Freeze Panes. The frozen rows must be tall enough to hold the control. A slicer that extends below the freeze line scrolls partly out of view, which looks broken.
Also consider turning off gridlines on the dashboard sheet (View > Gridlines). Gridlines behind slicers add visual noise.
Protect the layout
If you share the report, readers can accidentally drag or resize a control. Protecting the sheet stops that, but it also stops filtering unless you allow it:
- Right-click each control, open Size and Properties > Properties, and clear Locked. A locked control cannot be clicked on a protected sheet.
- Choose Review > Protect Sheet.
- Tick Use PivotTable & PivotChart in the list of allowed actions.
- Protect the sheet, then test: click an item in each control while the sheet is protected.
If a control still does not respond, return to the Protect Sheet dialog and check whether your Excel version also needs Edit objects ticked. That option lets readers move controls, so test it and decide whether the trade-off is acceptable.
Arrange controls with VBA
If you rebuild dashboards often, a macro saves manual alignment. This macro places every slicer on the active sheet in one row, starting at cell B2. It uses the shape position properties of each slicer.
Sub LayoutSlicerRow()
Dim sc As SlicerCache
Dim sl As Slicer
Dim x As Double
Dim anchor As Range
Set anchor = ActiveSheet.Range("B2")
x = anchor.Left
For Each sc In ActiveWorkbook.SlicerCaches
If sc.Name Like "Slicer_*" Then
For Each sl In sc.Slicers
If sl.Shape.Parent.Name = ActiveSheet.Name Then
sl.Top = anchor.Top
sl.Left = x
sl.Width = 140
sl.Height = 120
sl.NumberOfColumns = 1
x = x + sl.Width + 10
End If
Next sl
End If
Next sc
End SubThe Like "Slicer_*" test skips timeline caches, which have a different name pattern and do not support NumberOfColumns. The values 140, 120, and 10 are in points, so change them to fit your sheet.
Common layout mistakes
- Controls placed over PivotTables. A growing PivotTable ends up under a slicer, and readers cannot see the data. Keep controls clear of every PivotTable's possible range.
- Too many controls. Five or more slicers crowd the sheet. Keep the ones readers actually use, and move rarely used filters into report filters on the data sheet.
- A control that filters nothing visible. Check Report Connections for each control. A slicer that only connects to a hidden PivotTable looks like it does nothing.
- Unlabelled timelines. A timeline with no header gives no hint about which date field it filters, such as order date or ship date.
- Fixed sizes that fit one screen only. A layout that works on your monitor can overflow a laptop screen. Test at 100% zoom on a smaller display.
Exercise
A dashboard sheet has a timeline and three slicers in a top band. When a colleague hides column D to print the sheet, one slicer becomes too narrow to read, and another slicer cannot be clicked on the shared copy, which is protected. Which two settings should you change on the controls?
Show answer
Set each control's placement property to "Move but don't size with cells" so hiding a column does not resize it. Then clear the Locked option on each control, protect the sheet with "Use PivotTable & PivotChart" allowed, and test clicking each control while protected.
Exercise
Why does renaming a slicer in the Selection Pane not change the name used in ActiveWorkbook.SlicerCaches("Slicer_Region")?
Show answer
The Selection Pane renames the shape on the sheet. The slicer cache name is a separate workbook-level name. VBA code that refers to a SlicerCaches item uses the cache name.