Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Pivot Table programming problem

Dim pvt as PivotTable
Dim pitm as PivotItem
Dim s as String
s = "abc"
Set pvt = ActiveSheet.PivotTables("PivotTable1")
For Each pitm In pvt.PageFields("Project").PivotItems
If lcase(pitm.Value) = lcase(s) Then
pvt.PageFields(1).CurrentPage = pitm.Value
Exit For
End If
Next

I usually try to use the value of the pivot item to actually set the
pagefield as I have had problems myself trying to set it to the string value
(eventhough it appears to be a match).


--
Regards,
Tom Ogilvy



"DoctorG" wrote:

I have set up a Pivot with a page field (ProjectCode) so as to total 5
different fields for a given Project. I then use a Module Level Public
Function to change this
ActiveSheet.PivotTables("PivotTable1").PivotFields ("Project").CurrentPage =
<the function parameter and return the 5 values to the program that called
the Function.

If the parameter value exists in the Pivot field values my code works fine.
If it does not exist in the list though I get an error message at runtime. Is
there a way to get around this situation? How can I test if the parameter
exists in the list of the Pivot field values?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Pivot Table programming problem

Thanks a lot Tom... A precise and complete reply, as always.

"Tom Ogilvy" wrote:

Dim pvt as PivotTable
Dim pitm as PivotItem
Dim s as String
s = "abc"
Set pvt = ActiveSheet.PivotTables("PivotTable1")
For Each pitm In pvt.PageFields("Project").PivotItems
If lcase(pitm.Value) = lcase(s) Then
pvt.PageFields(1).CurrentPage = pitm.Value
Exit For
End If
Next

I usually try to use the value of the pivot item to actually set the
pagefield as I have had problems myself trying to set it to the string value
(eventhough it appears to be a match).


--
Regards,
Tom Ogilvy



"DoctorG" wrote:

I have set up a Pivot with a page field (ProjectCode) so as to total 5
different fields for a given Project. I then use a Module Level Public
Function to change this
ActiveSheet.PivotTables("PivotTable1").PivotFields ("Project").CurrentPage =
<the function parameter and return the 5 values to the program that called
the Function.

If the parameter value exists in the Pivot field values my code works fine.
If it does not exist in the list though I get an error message at runtime. Is
there a way to get around this situation? How can I test if the parameter
exists in the list of the Pivot field values?

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
Pivot Table Programming Matt Childs Excel Programming 2 October 21st 05 06:22 PM
Excel vba pivot table programming [email protected] Excel Programming 2 March 11th 05 04:34 AM
Pivot Table Programming Marvin Excel Programming 1 January 25th 05 10:54 PM
Pivot Table Programming OrrLyfe Excel Programming 3 November 1st 04 12:44 AM
Pivot table Programming Kris Excel Programming 1 October 5th 04 09:03 PM


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