ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Un-pivot (https://www.excelbanter.com/excel-programming/380548-un-pivot.html)

[email protected]

Un-pivot
 
I have several large pivot tables that really should not be pivot
tables. All they do is filter. I would like to do 1 of 2 things. Either
somehow convert these to just filters or to make a VBA program that
does the filtering. (That last option makes sense since all we do with
the table is convert some data to an output text file with a macro. So
why not do it all in the macro.) So, anyway, here are my questions:

1) How can I convert the tables to regular filtered sheets?

2) How can I, other than hand typing, capture the filter choices? There
are scores and scores of these selected and I will certainly mess up if
I just hand copy. Is there VBA access to this?

TIA


[email protected]

Un-pivot
 

Tom Ogilvy wrote:
You can make a pivot table just cells containing data by selecting the whole
table and doing Edit=Copy, then immediatly doing Edit=Paste Special and
select Values.

This however is not a filter - it is just unchangeable results of applying a
"filter". there is no built in way to transform a pivot table into a
filtered copy of the original data.

In vba, you can loop through the items of the pivotTable

Sub abc()
Dim sh as worksheet, pTbl as PivotTable
Dim pFld as PivotField, pitm as PivotItem
Set sh = Worksheets("Sheet3")
Set pTbl = sh.PivotTables("PivotTable1")
Set pFld = pTbl.PivotFields("Header2")
For Each pitm In pFld.PivotItems
Debug.Print pitm.Value, pitm.Visible
Next
End Sub

produced:

B True
C False
A True
D False

The true items were selected in the dropdown


Thanks, that should save me lots of work.


" wrote:

I have several large pivot tables that really should not be pivot
tables. All they do is filter. I would like to do 1 of 2 things. Either
somehow convert these to just filters or to make a VBA program that
does the filtering. (That last option makes sense since all we do with
the table is convert some data to an output text file with a macro. So
why not do it all in the macro.) So, anyway, here are my questions:

1) How can I convert the tables to regular filtered sheets?

2) How can I, other than hand typing, capture the filter choices? There
are scores and scores of these selected and I will certainly mess up if
I just hand copy. Is there VBA access to this?

TIA





All times are GMT +1. The time now is 09:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com