filtro horizontal de columnas con fechas PivotItem visible
publicado
Buenas tardes.
He logrado adaptar un filtro horizontal de columnas a mis necesidades a traves de una tabla dinamica.
Con los campos texto no hay problema. El problema viene cuando lo que queremos filtrar son fechas. Por lo que veo .PivotItems adopta la fecha en formato ingles.
en las columnas ha filtrar lo he solucionado conviertiendolas a texto:
dim str as string:str = c.value: set pi= Set pi = .PivotItems(str)
el problema es con el origen de la tabladinamica donde para que funcione tengo que añadir un ' a cada fecha y de esta manera convertirlas en texto
He probado de todo.............incluso cambiar la tabla dias a un formato de fechas no regional pero no hay manera.
Si alguien se le ocurre algo que me pueda ayudar agradeceria la ayuda.
un saludo.
Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
Select Case Target.Name
Case "TablaDinámica1"
Call m_FilterCol.Filter_Columns("x", "INFORME", "INFORME", "TablaDinámica1", "DIAS")
End Select
End Sub
sReportSheet As String, _
sPivotSheet As String, _
sPivotName As String, _
sPivotField As String _
)
Dim c As Range
Dim rCol As Range
Dim pi As PivotItem
Dim str As String
'
'
'
Worksheets(sReportSheet).Range(sHeaderRange).EntireColumn.Hidden = False
'
'
For Each c In Worksheets(sReportSheet).Range(sHeaderRange).Cells
str = c.Value
With Worksheets(sPivotSheet).PivotTables(sPivotName).PivotFields(sPivotField)
On Error Resume Next
Set pi = .PivotItems(str)
On Error GoTo 0
End With
'
If Not pi Is Nothing Then
If pi.Visible = False Then
If rCol Is Nothing Then
Set rCol = c
Else
Set rCol = Union(rCol, c)
End If
End If
End If
'
Set pi = Nothing
'
Next c
'
If Not rCol Is Nothing Then
rCol.EntireColumn.Hidden = True
End If
End Sub
Buenas tardes.
He logrado adaptar un filtro horizontal de columnas a mis necesidades a traves de una tabla dinamica.
Con los campos texto no hay problema. El problema viene cuando lo que queremos filtrar son fechas. Por lo que veo .PivotItems adopta la fecha en formato ingles.
en las columnas ha filtrar lo he solucionado conviertiendolas a texto:
dim str as string:str = c.value: set pi= Set pi = .PivotItems(str)
el problema es con el origen de la tabladinamica donde para que funcione tengo que añadir un ' a cada fecha y de esta manera convertirlas en texto
He probado de todo.............incluso cambiar la tabla dias a un formato de fechas no regional pero no hay manera.
Si alguien se le ocurre algo que me pueda ayudar agradeceria la ayuda.
un saludo.
Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable) Select Case Target.Name Case "TablaDinámica1" Call m_FilterCol.Filter_Columns("x", "INFORME", "INFORME", "TablaDinámica1", "DIAS") End Select End Sub
sReportSheet As String, _ sPivotSheet As String, _ sPivotName As String, _ sPivotField As String _ ) Dim c As Range Dim rCol As Range Dim pi As PivotItem Dim str As String ' ' ' Worksheets(sReportSheet).Range(sHeaderRange).EntireColumn.Hidden = False ' ' For Each c In Worksheets(sReportSheet).Range(sHeaderRange).Cells str = c.Value With Worksheets(sPivotSheet).PivotTables(sPivotName).PivotFields(sPivotField) On Error Resume Next Set pi = .PivotItems(str) On Error GoTo 0 End With ' If Not pi Is Nothing Then If pi.Visible = False Then If rCol Is Nothing Then Set rCol = c Else Set rCol = Union(rCol, c) End If End If End If ' Set pi = Nothing ' Next c ' If Not rCol Is Nothing Then rCol.EntireColumn.Hidden = True End If End Sub
pruebas_ayuda.xlsm