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!
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!