Excel PivotTable Field Selection

Copper Contributor

Every time I select a field for a pivot table, the PivotTable Fields dialogue box collapses back to its original state.  I'd like to select multiple fields without having to drill to the specific field folder each time.  Is there a setting that controls this?  The data source is an attached database.

1 Reply

@US285126 

Excel does not provide a direct setting to change this specific behavior. There are a few workarounds that might help you manage the field selection process more efficiently. Workarounds are not tested backup your file first.

Workarounds to Manage PivotTable Field Selection

  1. Pin the PivotTable Fields Pane:
    • While not a direct solution to the collapsing issue, pinning the PivotTable Fields pane can help keep it open and make it easier to navigate.
    • To pin the pane, click on the pin icon (pushpin) in the upper right corner of the PivotTable Fields pane. This will keep the pane docked and always visible.
  2. Use the Field List in a Larger Area:
    • Resize the PivotTable Fields pane to make it larger. This can be done by clicking and dragging the edges of the pane to increase its size, making it easier to navigate and select multiple fields.
  3. Add Fields in Bulk:
    • Instead of dragging fields one by one, you can select multiple fields at once and drag them together. This is done by holding the Ctrl key (Cmd key on Mac) and clicking on each field you want to add. Then, drag them to the desired area (Rows, Columns, Values, or Filters).
  4. Use the Search Box:
    • If your PivotTable Fields pane supports it, use the search box at the top of the pane to quickly locate and select fields. This can reduce the amount of scrolling and collapsing/expanding required.
  5. Manual Adjustment of Fields:
    • After adding the initial fields, you can manually rearrange them within the PivotTable Fields pane without needing to go back to the original folder structure each time. This way, you avoid the collapsing issue once the fields are initially placed.
  6. Excel Add-ins or VBA:
    • If you frequently work with complex PivotTables, consider using Excel add-ins or VBA macros to automate some of the field management tasks. While this requires a bit of setup, it can save time in the long run.

VBA Macro Example to Add Multiple Fields

Here's a simple VBA macro to add multiple fields to the PivotTable:

  1. Press Alt + F11 to open the VBA editor.
  2. Insert a new module by right-clicking on any existing module or the VBAProject, selecting Insert, and then Module.
  3. Paste the following code into the module:

Vba Code is untested backup your file first.

Sub AddPivotFields()
    Dim pt As PivotTable
    Dim pf As PivotField
    Dim ws As Worksheet
    
    ' Change "Sheet1" to the name of your worksheet
    Set ws = ThisWorkbook.Worksheets("Sheet1")
    
    ' Change "PivotTable1" to the name of your PivotTable
    Set pt = ws.PivotTables("PivotTable1")
    
    ' List of fields to add
    Dim fieldsToAdd As Variant
    fieldsToAdd = Array("Field1", "Field2", "Field3") ' Change field names accordingly
    
    ' Add fields to the PivotTable
    For Each field In fieldsToAdd
        Set pf = pt.PivotFields(field)
        pf.Orientation = xlRowField ' Change to xlColumnField, xlDataField, or xlPageField as needed
    Next field
End Sub

Adjust the worksheet name, PivotTable name, and field names in the code as needed.

  1. Run the macro by pressing F5 or by going back to Excel and running the macro from the Developer tab (or View tab under Macros).

Using these workarounds and tools should help you manage the PivotTable Fields more effectively and mitigate the frustration caused by the collapsing pane. The text, steps and vba code were created with the help of AI.

 

My answers are voluntary and without guarantee!

 

Hope this will help you.

Was the answer useful? Mark as best response and Like it!

This will help all forum participants.