Unchecking pivot rowfileld's items dropdown filter ?

narendramaruti

New Member
Joined
Dec 21, 2009
Messages
4
Hi,
I have a pivot table that extract data from OLAP Cube. In the RowFields ,there is a dropdown list contains DATE values. I am trying to hide dates that are not in current year. But when i am using to find the list of values that are in DropDown choice , the following code acually returning the values that are actually displaying on the sheet rather than the values in the dropdown.

Code:

For Each pvtField In pvtTable.RowFields
Debug.Print pvtField.PivotItems.Count
'Debug.Print pvtField.Name
For Each itm In pvtField.PivotItems
strCompareString = Replace(Replace(Right(itm, Len(itm) - InStr(1, itm, "&", vbTextCompare)), "[", ""), "]", "")
For jYears = 2003 To 2008 ' DataAvailableYear to CurrentYear - 1
For jMonths = 3 To 14
DtSerial = DateSerial(jYears, jMonths - 1, 1 - 1)
InputDate = DtSerial '"2009-01-31"
cntDiff = DateDiff("d", InputDate, DateValueOfConstant)

subStr = CStr(DateConstant - cntDiff)
'myStr = "[SOLD-DATE].[SOLD-DATE].&[" + subStr + "]"
'Debug.Print InputDate & " ---" & subStr
'Hide old years data
If (subStr = strCompareString) Then
ReDim Preserve arrSoldEndOfMonth(iTmp)
Debug.Print InputDate & " ---" & subStr
arrSoldEndOfMonth(iTmp) = "[SOLD-DATE].[SOLD-DATE].&[" & subStr & "]"
iTmp = iTmp + 1
End If
Next jMonths
Next jYears
Next itm
Next pvtField

On Error Resume Next
Debug.Print iTmp
'pvTable.ManualUpdate = True
pvtField.CubeField.EnableMultiplePageItems = True

ActiveSheet.PivotTables("PivotTable2").PivotFields( _
"[SOLD-DATE].[SOLD-DATE].[SOLD-DATE]").HiddenItemsList = _
arrSoldEndOfMonth()

I want to hide (uncheck) the dates in the DATE drop down which are not in current year.
Please help.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top