Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help needed with Pivot table macro to remove data
Hi I have a macro that creates a pivot table but what I need if for each
column of data that does not include the word "Student" to be removed: So starting at column b the first column header in the pivot table would be in cell B3 and if this cell does not have the word Student within the text string then that column needs to be removed! Hope you understand? Regards Neil |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help needed with Pivot table macro to remove data
You could loop through the column fields and their items:
Sub test() Dim pt As PivotTable Dim pf As PivotField Dim pi As PivotItem Dim strHide As String Set pt = ActiveSheet.PivotTables(1) strHide = "student" For Each pf In pt.ColumnFields Debug.Print pf.Name For Each pi In pf.PivotItems Debug.Print pi.Name If InStr(1, UCase(pi.Caption), UCase(strHide)) 0 Then pi.Visible = False Else pi.Visible = True End If Next pi Next pf End Sub Nelly wrote: Hi I have a macro that creates a pivot table but what I need if for each column of data that does not include the word "Student" to be removed: So starting at column b the first column header in the pivot table would be in cell B3 and if this cell does not have the word Student within the text string then that column needs to be removed! Hope you understand? Regards Neil -- Debra Dalgleish Contextures http://www.contextures.com/tiptech.html |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Is Data Needed After Pivot Table is Created? | Excel Discussion (Misc queries) | |||
Pivot Table Data - Troubleshoot needed | Excel Discussion (Misc queries) | |||
Pivot Table Data - Troubleshoot needed | Excel Worksheet Functions | |||
Pivot Table Data - Troubleshoot needed | Excel Discussion (Misc queries) | |||
Macro Needed for Pivot Table | Excel Programming |