I was looking at an Excel Pivot table and chart for moving to MS SQL Report Builder, and in that process, I came across one that had a filter with MANY items checked, and MANY items unchecked.
So for easier viewing and discussion, I thought it'd be nice to do a Debug.Print on all the items (or maybe would be better to list out in a new worksheet.
Regardless of where to put the list, I set off to finding how to do that. I did not find any direct results in a blog or forum, so I thought I'd go to testing on my own. I did find a couple of pretty neat methods for listing fields from a pivot table here:
However, those examples still don't give me what I'm after - nifty, and could be useful at times, but not for what I want to do.
Mostly what I've been able to do so far is get "application defined error" and others, trying to mess with a few objects.
I didn't keep all my attempts... tried, then deleted when didn't work and started from scratch. But regardless, here is my last attempt - please do not laugh.
What I got from that was a few lines of nulls or null strings.
Thanks in advance. This isn't something I have to have right now, b/c ended up logically eliminating the filter altogether. However, I'd like to figure this one out for future cases I might run into, and some could come pretty soon, as I'm converting loads of reports from Excel to Reporting Services.
"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
So for easier viewing and discussion, I thought it'd be nice to do a Debug.Print on all the items (or maybe would be better to list out in a new worksheet.
Regardless of where to put the list, I set off to finding how to do that. I did not find any direct results in a blog or forum, so I thought I'd go to testing on my own. I did find a couple of pretty neat methods for listing fields from a pivot table here:
However, those examples still don't give me what I'm after - nifty, and could be useful at times, but not for what I want to do.
Mostly what I've been able to do so far is get "application defined error" and others, trying to mess with a few objects.
I didn't keep all my attempts... tried, then deleted when didn't work and started from scratch. But regardless, here is my last attempt - please do not laugh.
Code:
Sub PivotTableExplorer()
Dim wb As Workbook
Dim ws As Worksheet
Dim pt As PivotTable
Dim pf As PivotField
Dim pfl As PivotFilter
Set wb = ActiveWorkbook
Set ws = wb.ActiveSheet
Set pt = ws.PivotTables("PivotTable11")
Set pt = ActiveSheet.PivotTables("PivotTable11")
For Each pf In pt.PivotFields
'If pf.IsCalculated Then
For Each pfl In pf.PivotFilters
Debug.Print pfl.Description
Next pfl
'End If
Next pf
End Sub
What I got from that was a few lines of nulls or null strings.
Thanks in advance. This isn't something I have to have right now, b/c ended up logically eliminating the filter altogether. However, I'd like to figure this one out for future cases I might run into, and some could come pretty soon, as I'm converting loads of reports from Excel to Reporting Services.
"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57