Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
 
Posts: n/a
Default how to remove "(All)" in a pivot table using VBA

hi everyone!
does anyone know if it is possible to remove the "(All)"
or "(Show All)" from a pivot table.

here's a piece of my code for setting up the first
element of each pagefeild items, but I would also want to
remove the field "(All)"

With ActiveWorkbook.PivotCaches.Add
(SourceType:=xlExternal)
.Connection = strConnection
.CommandType = xlCmdSql
.CommandText = "exec
fc_GetViewAsDenormalizedTable @View_id=" & intViewID & ",
@tableset=" & intTableset
.CreatePivotTable
TableDestination:=ActiveSheet.Range("A3"),
TableName:="PivotTable1",
DefaultVersion:=xlPivotTableVersion10
End With

Set pt = ActiveSheet.Range("A3").PivotTable

For Each ptField In pt.PivotFields
If LCase(ptField.Name) < "data_id" And LCase
(ptField.Name) < "usertable_login" And LCase
(ptField.Name) < "view_id" And LCase(ptField.Name)
< "transfert_date" And LCase(ptField.Name)
< "control_code" Then
Select Case LCase(ptField.Name)
Case "cou"
ptField.Orientation = xlRowField
Case "country"
ptField.Orientation = xlRowField
Case "dcountry"
ptField.Orientation = xlRowField
Case "yea"
ptField.Orientation = xlColumnField
Case "year"
ptField.Orientation = xlColumnField
ptField.ShowAllItems = False
Case "data_value"
pt.AddDataField ptField
Case Else
ptField.Orientation = xlPageField
strFirstMember = ptField.PivotItems(1)
ptField.CurrentPage = strFirstMember
End Select
End If
Next ptField

pt.RowGrand = False
pt.ColumnGrand = False
pt.NullString = ".."
  #2   Report Post  
Debra Dalgleish
 
Posts: n/a
Default

You can't suppress the "All" option in the page field. With programming,
you could select another item if the user selects "All".

For example:
'========================
Private Sub Worksheet_Change(ByVal Target As Range)
Dim pt As PivotTable
Dim pf As PivotField
Set pt = Me.PivotTables(1)
Set pf = pt.PivotFields("Rep")

With pf
If .CurrentPage = "(All)" Then
.CurrentPage = .PivotItems(1).Name
End If
End With
End Sub
'============================

This code is stored on the worksheet's code module --
Right-click the sheet tab, and choose View Code
Paste the code where the cursor is flashing.


wrote:
hi everyone!
does anyone know if it is possible to remove the "(All)"
or "(Show All)" from a pivot table.

here's a piece of my code for setting up the first
element of each pagefeild items, but I would also want to
remove the field "(All)"

With ActiveWorkbook.PivotCaches.Add
(SourceType:=xlExternal)
.Connection = strConnection
.CommandType = xlCmdSql
.CommandText = "exec
fc_GetViewAsDenormalizedTable @View_id=" & intViewID & ",
@tableset=" & intTableset
.CreatePivotTable
TableDestination:=ActiveSheet.Range("A3"),
TableName:="PivotTable1",
DefaultVersion:=xlPivotTableVersion10
End With

Set pt = ActiveSheet.Range("A3").PivotTable

For Each ptField In pt.PivotFields
If LCase(ptField.Name) < "data_id" And LCase
(ptField.Name) < "usertable_login" And LCase
(ptField.Name) < "view_id" And LCase(ptField.Name)
< "transfert_date" And LCase(ptField.Name)
< "control_code" Then
Select Case LCase(ptField.Name)
Case "cou"
ptField.Orientation = xlRowField
Case "country"
ptField.Orientation = xlRowField
Case "dcountry"
ptField.Orientation = xlRowField
Case "yea"
ptField.Orientation = xlColumnField
Case "year"
ptField.Orientation = xlColumnField
ptField.ShowAllItems = False
Case "data_value"
pt.AddDataField ptField
Case Else
ptField.Orientation = xlPageField
strFirstMember = ptField.PivotItems(1)
ptField.CurrentPage = strFirstMember
End Select
End If
Next ptField

pt.RowGrand = False
pt.ColumnGrand = False
pt.NullString = ".."



--
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
Using a Pivot Table Calculated Field to get a Unique Count Mike Struckman Excel Worksheet Functions 1 November 22nd 05 05:32 PM
How to remove Drop Page Fields Here from Pivot Table wengyee Excel Discussion (Misc queries) 2 June 3rd 05 10:36 PM
pivot table yllee70 Excel Worksheet Functions 1 February 21st 05 10:49 PM
Removing errors from a Pivot table Mighty Magpie Excel Discussion (Misc queries) 2 February 3rd 05 03:15 PM
Problem with Pivot Table Drop-Down Menus Mac Excel Worksheet Functions 4 November 7th 04 01:18 PM


All times are GMT +1. The time now is 07:46 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"