Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is Data Needed After Pivot Table is Created? roadkill Excel Discussion (Misc queries) 1 May 22nd 07 12:57 PM
Pivot Table Data - Troubleshoot needed aly1cat Excel Discussion (Misc queries) 4 August 4th 06 10:18 PM
Pivot Table Data - Troubleshoot needed aly1cat Excel Worksheet Functions 1 June 28th 06 01:49 PM
Pivot Table Data - Troubleshoot needed aly1cat Excel Discussion (Misc queries) 1 June 28th 06 01:48 PM
Macro Needed for Pivot Table [email protected] Excel Programming 3 December 12th 05 04:01 PM


All times are GMT +1. The time now is 10:36 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"