Hiding pivotitems matching with external criteria

Yohn

New Member
Joined
Aug 10, 2011
Messages
5
Hi, I have a pivottable where I want to "filter" some data depending on if they are in other table or not, the data I want to filter are alphanumeric names. My idea is to save the data (names) in an array and then compare the pivotitems to the array items and set visible the matches but it doesn't worked.

I tried extracting the numeric part of the names (most names are CIRA#### or INFA####) and dealing with numbers only, I tried saving the name as text in the array (with text function) and even I put one specific name in the condition but the bucle just don't recognize any match. Could you please tell me what is wrong with my code?

Sub Indicadores()
Dim pt As PivotTable
Dim pi As PivotItem
Dim pozo() As String

Application.ScreenUpdating = False

Set pt = ActiveSheet.PivotTables("Prueba")
pt.ManualUpdate = True
ActiveWorkbook.Sheets("Pozos 2011").Select
Cells(1, 4).Select
Selection.End(xlDown).Select
filas = ActiveCell.Row
cont = 1
While cont <= filas
ReDim Preserve pozo(cont + 1) As String
pozo(cont) = Cells(cont, 4).Value
cont = cont + 1
Wend
For Each pi In pt.PivotFields("ORDEN DE TRABAJO").PivotItems
cont2 = 1
While cont2 <= filas
Select Case pi.Value
Case pi.Value = "1054*" 'pozo(cont2)
pi.Visible = True
GoTo 10
Case Else
pi.Visible = False
cont2 = cont2 + 1
End Select
Wend
10
Next pi
pt.ManualUpdate = False

Application.ScreenUpdating = True

End Sub

I hope you can help me guys!
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Thank you so much Jerry, I appreciate your help. Your code works great, my case was easier than the one on the other thread.

I would like to know what was wrong with my code anyways. Could you tell me why the program didn't find any match even when looking for a specific value you knew it was on the pivottable? I thought it was because the kind of variable (text, number) but none of my changes worked.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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