When we create a pivot table, we need to drag the fields into the Row Labels or Values manually one by one. If we have a long list of fields, we can add a few row labels quickly, but the remaining fields should be added to the Value area. Are there any quick methods for us to add all the other fields into the Value area with one click in the pivot table?
Unfortunately, there is no checkbox for us to quickly check all the fields in the Pivot Table Field List with one click, but, with the following VBA code it can help you to add the remaining fields to the Values area at once. Please do as follows:
1. After creating the pivot table, firstly, you should add the row label fields as your need, and leaving the value fields in the Choose fields to add to report list, see screenshot:< /p>
2. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.
3. Click Insert > Module, and paste the following code in the Module Window.
VBA code: Add multiple fields into Value area of pivot tables in active worksheet
Dim pt As PivotTable
Dim I As Long
For Each pt In ActiveSheet.PivotTables
For I = 1 To pt.PivotFields.Count
If .Orientation = 0 Then .Orientation = xlDataField
4. Then press F5 key to run this code, all the remaining fields have been added to the Values area at same time, see screenshot:
Note: This VBA code is applied to all pivot tables of active worksheet.
Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
More than 300 powerful features. Supports Office/Excel
2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features
30-day free trial. 60-day money back guarantee.
If "Values are "0" or "Null" how to suppress Row Values from Displaying
(ex. Sum of 2743 Difference)
Pivot "Rows" Pivot "Values"
NP9 - Total Unexpended Appropriations
Sum of OTHER Difference 1,045,355,165.31
Sum of 3200 Difference
0.00 Sum of 0108 Difference 12,873,630.29
Sum of 4586 Difference
(33,024,706.93) Sum of 0148 Difference (72,046,783.14)
Sum of 0129 Difference
(5,583,891.98) Sum of 4598 Difference (929,574.56)
Sum of 2743 Difference Sum of 4041 Difference 0.00
Sum of 2799 Difference
Does "xlDataField" not work with PowerPivot? I've got the code below, which is used to add all measures to the pivot table. It works with "xlColumnField" and "xlRowField". Any ideas how to make this work?
Dim pt As PivotTable
Dim iCol As Long
Dim iColEnd As Long
Set pt = ActiveSheet.PivotTables(1)
iCol = 1
iColEnd = .CubeFields.Count
For iCol = 1 To iColEnd
With .CubeFields(iCol) If .Orientation = xlHidden Then
.Orientation = xlDataField End If
End With Next iCol
You can click on your field (in the area where you drag your fields into : column labels, row labels etc.) then click on "Value field setting" then you will get a dropdown list from where you can chose "Sum" !
Yeah, to echo markus, is there a way to edit the code to only add unchecked fields that have certainly field labels (like with an if contains function)? For example, I have a question that is actually 50 yes/no values by topic and I'd like to move all of those to the values field. They all begin with the same question label q9_[specific question topic].