Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Hide zero column in Pivotreport

Hello all

I have a number of process sections that I keep track of. It is how much was produced in each section per week. When I want to create a chart from this it would be nice to hide the zero columns. (Containing the weeks when nothing was produced.) I have a script for hiding zero rows, but I'm not able to transform it to columns also

Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default Hide zero column in Pivotreport

The following macro will hide the columns with zero total, in Excel 2002
or later, where the column field is "Rep", and data field is "Units"

'==========================
Sub HideZeroColumnTotals()
'hide columns that contain zero totals
'by Debra Dalgleish
Dim r As Integer
Dim i As Integer
Dim rTop 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
For Each pi In pf.PivotItems
On Error Resume Next
pi.Visible = True
Next pi
rTop = 4 'heading row
i = pf.PivotItems.Count
For r = i To 1 Step -1
On Error Resume Next
str = Cells(rTop, r).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
'===================================

Tobias wrote:
Hello all,

I have a number of process sections that I keep track of. It is how much was produced in each section per week. When I want to create a chart from this it would be nice to hide the zero columns. (Containing the weeks when nothing was produced.) I have a script for hiding zero rows, but I'm not able to transform it to columns also.

Thanks in advance.



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html

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 Column If Usedrange of Column ISBLANK Follow-up [email protected] Excel Discussion (Misc queries) 1 April 12th 09 10:00 PM
Hide Column If Usedrange of Column ISBLANK [email protected] Excel Discussion (Misc queries) 4 April 12th 09 09:47 PM
How to hide a column Pascale Excel Discussion (Misc queries) 4 February 27th 08 05:31 PM
Hide column or row based on a cell in the column or row? SacGuy Excel Discussion (Misc queries) 0 January 24th 06 06:51 PM
hide column varun New Users to Excel 1 December 3rd 04 02:13 AM


All times are GMT +1. The time now is 10:15 PM.

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

About Us

"It's about Microsoft Excel"