zeros in pivot tables

T

Tomasmexicali

Hi everybody,

I am working on an exell pivot table and I would like the pivot table not to
show the zeros on columns when the total for the line is actually zero. I
would like to supress this rows.

Do you have any input?

Thanks to all

Have a great day
 
E

Earl Kiosterud

Tomas,

You can set "Zero values" off in Tools - Options - View. It affects the
whole sheet.
 
D

Debra Dalgleish

The following code will hide the rows with zero total:

'==========================
Sub HideZeroRowTotals()
'hide rows that contain zero totals
'by Debra Dalgleish
Dim r As Integer
Dim rTop As Integer
Dim i As Integer
Dim pt As PivotTable
Dim pf As PivotField
Dim df As PivotField
Dim pi As PivotItem
Dim pd As Range
Dim str As String
Set pt = Sheets("Pivot").PivotTables(1)
Set df = pt.PivotFields("Units") 'data field
Set pf = pt.PivotFields("Rep") 'column field
rTop = 4 'number of rows before data starts
For Each pi In pf.PivotItems
On Error Resume Next
pi.Visible = True
Next pi
i = pf.PivotItems.Count + rTop
For r = i To rTop - 1 Step -1
On Error Resume Next
str = Cells(r, 1).Value
Set pd = pt.GetPivotData(df.Value, pf.Value, str)
If pd.Value = 0 Then
pf.PivotItems(str).Visible = False
End If
Next r

End Sub
'===================================
 
Top