LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Almost there... dynamic and conditional set of PivotItems


Ok, I've got the following situation:

Sheets("Inhoud") or s1, the place where the default values are kept i
cells A1:D10 (A = SheetName, B = PivotTablesName, C = PivotFieldsName
D = the default value)
Sheets("Contracten") or s2, with a PivotTable on it
Sheets("Afgelopen contracten") or s3, with a PivotTable on it
etc

I can set a default value to a PivotFields.PivotItems with this code:


Code
-------------------
' actually works with XP & Excel 2003
With Sheets("Aflopende contracten").PivotTables("PivotAFL").PivotFields(" AM")
Dim SPgField2 As Variant
s1.Range("D2").Select
SPgField2 = Selection
.CurrentPage = SPgField2
End Wit
-------------------


But then, it also sets the default value when the value wasn't presen
in the list before!!

I tried to make this piece of code conditional as you can see below...


Code
-------------------
' doesn't work... :S
Dim i As Long
With Sheets("Aflopende contracten").PivotTables("PivotAFL").PivotFields(" AM") 'Sheets("Aflopende contracten") = s3
For i = 1 To .PivotItems.Count
If .PivotItems(i) = s1.Range("D2").Select Then
Dim SPgField1 As Variant
s1.Range("D2").Select
SPgField1 = Selection
.CurrentPage = SPgField1
MsgBox ("OK / i=" & i)
Else
MsgBox ("NO / i=" & i)
End If
Next i
End Wit
-------------------


But that isn't working, it somehow fails to recognize the value in th
if-statement, all I got was the NO message...

Anyone, who knows how to fix this?? I'm running XP with Excel 2003.

Ok, that was my first question. Now the second. How can I make the cod
dynamic so I can use it as a Function? Or how can I get the SheetsName
PivotTablesName and PivotFieldsName from s1 (Sheets("Inhoud")) column
A:C?

It would be awesome if we can get this working ;

--
s80N

-----------------------------------------------------------------------
s80NL's Profile: http://www.excelforum.com/member.php...fo&userid=3637
View this thread: http://www.excelforum.com/showthread.php?threadid=56196

 
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
Controlling Pivotitems.visible sxhwabbiemike Excel Discussion (Misc queries) 0 January 21st 09 03:09 AM
Adding PivotItems Geoff Excel Programming 0 April 12th 06 09:10 AM
Always keep the same 4 PivotItems visible Martin[_21_] Excel Programming 2 April 27th 05 10:17 AM
pivotitems in a multiuser environment Kanan Excel Programming 0 March 3rd 04 05:16 PM
Add PivotItems to PivotTable / Enabling - Disabling PivotItems Ole[_3_] Excel Programming 1 July 8th 03 03:24 PM


All times are GMT +1. The time now is 07:21 AM.

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"