In a DataCycle Reporting (DCR) report that contains a Pivot Table, it is possible to automatically filter the Pivot Table using the DCR "Run Macro" task. To do this, you can use the following macro, which must be included in the report template design:
DCR "Run Macro" task configuration:
Macro: FilterPivotTable
Parameters: Field to filter, Value to filter
Macro to include in the report design (within the Excel template's VBA code):
---
Sub filtraTD(fieldname As String, Value As String)
Dim pt As PivotTable
Dim apfield As PivotField
If Value = "" Then Exit Sub
Set pt = Sheets("Visión Dinámica").PivotTables("Cubo")
Set apfield = pt.PivotFields(fieldname)
apfield.CurrentPage = Value
If apfield.CurrentPage <> Value Then
MsgBox "Error:" & Err.Description
End If
End Sub
---
This macro is valid if the template contains a worksheet named "Visión Dinámica" and a Pivot Table named "Cubo".
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article