Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
maryj
 
Posts: n/a
Default hide 0 values in ptable

I found this code published by Debra Dalgleish. I've tried unsuccessfully to
modify it for my file.

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("Summary Pivot").PivotTables(1)
Set df = pt.PivotFields("2005 Vol") 'data field
Set pf = pt.PivotFields("Customer") 'column field
rTop = 7 '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

I have changed the sheet and field names. The difference is that I have 2
row fields and just wasn't sure how to add that to the code. The macro works
perfectly if I only have the one row field, but I need to include another row
field called "segment".

Thanks for your help!
--
maryj
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hide all values in a row if value is 0 Erik T Excel Worksheet Functions 1 March 16th 06 12:20 AM
I Need a formula to evaluate a cell with + or - values Bob in Oklahoma Excel Worksheet Functions 6 October 31st 05 02:41 PM
Return Range of Numerical Values in Single Column based on Frequency Percentage Sam via OfficeKB.com Excel Worksheet Functions 9 October 28th 05 11:01 PM
How do I hide 0 values in line charts Stephan Charts and Charting in Excel 2 April 12th 05 12:55 PM
Excel - hide erroer values Kathrine J Wathne Excel Discussion (Misc queries) 1 January 10th 05 10:13 PM


All times are GMT +1. The time now is 11:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"