Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Finding CurrentPage in PivotTable

Hi there,

Is there a way to test to see if an Item is in the list of PivotField,
before setting the CurrentPage to that item? The reason I ask is if you don't
check first to make sure the item exists, then set the CurrentPage to the
item you want, it creates that item for you, which is not what I want it to
do.

Cheers,
Grant.

ActiveWorkbook.Worksheets(wkSheet.Name).PivotTable s(pvtTable.Name).PivotFields("Line").CurrentPage = sStr
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default Finding CurrentPage in PivotTable

You can check if the item exists:

'========================
Sub ChangePivotPage()
On Error Resume Next
Dim ws As Worksheet
Dim pt As PivotTable
Dim pi As PivotItem
Dim str As String
Set ws = ActiveSheet
Set pt = ws.PivotTables(1)
str = ws.Range("E2").Value

With pt.PageFields("Rep")
'Test if Item exists
Set pi = .PivotItems(str)
On Error GoTo 0
If pi Is Nothing Then
MsgBox str & " is not an item in the Rep field"
Else
.CurrentPage = str
End If
End With

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

Grant wrote:
Hi there,

Is there a way to test to see if an Item is in the list of PivotField,
before setting the CurrentPage to that item? The reason I ask is if you don't
check first to make sure the item exists, then set the CurrentPage to the
item you want, it creates that item for you, which is not what I want it to
do.

Cheers,
Grant.

ActiveWorkbook.Worksheets(wkSheet.Name).PivotTable s(pvtTable.Name).PivotFields("Line").CurrentPage = sStr



--
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
Creating a PivotTable w/o selecting data in an existing PivotTable Damian Excel Discussion (Misc queries) 6 November 2nd 07 04:44 PM
Finding a row/column header in Pivottable Steven Cheng Excel Worksheet Functions 5 June 16th 07 12:22 AM
PivotTable - PivotTable Field name is not valid - error! miker1999[_17_] Excel Programming 1 June 10th 04 10:30 AM
weird problem with PivotFields CurrentPage Chrysalis Excel Programming 0 April 22nd 04 01:51 AM
Pivotfields.CurrentPage Daniel Magnus Bennét Björck Excel Programming 5 February 6th 04 02:48 PM


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