#1
|
|||
|
|||
Include and Exclude items through vba in pivot table
I need to create a macro to use on monthly reports where I can include only certain vendor number from a list of 100 or more (number changes each month). I need to include these certain ones ONLY each time. I've create this vba but it's not working for some reason. Is there a better way or what changes are needed in this formula:
Dim pItem As PivotItem With ActiveSheet.PivotTables("PivotTable2").PivotFields ("Vndr Id Cd") For Each pItem In .PivotItems If (pItem = "2304013") Then pItem.Visible = True If (pItem = "2706002") Then pItem.Visible = True If (pItem = "2706003") Then pItem.Visible = True If (pItem = "4601504") Then pItem.Visible = True If (pItem = "5201064") Then pItem.Visible = True If (pItem <> "2304013") Then pItem.Visible = False If (pItem <> "2706002") Then pItem.Visible = False If (pItem <> "2706003") Then pItem.Visible = False If (pItem <> "4601504") Then pItem.Visible = False If (pItem <> "5201064") Then pItem.Visible = False If (pItem = "(blank)") Then pItem.Visible = False Next End With Mike |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Include/Exclude Table(s) from OnEnter event | warbird | Word VBA | 7 | 07-14-2015 05:10 AM |
Selecting/deselecting items in pivot table | mbesspiata | Excel | 0 | 07-22-2014 08:15 AM |
VBA Pivot Table CubeField Enable multiple items | Wries | Excel Programming | 0 | 03-13-2014 09:56 AM |
Docx to PDF: Exclude heading from TOC but include in bookmarks | Lebber | Word | 8 | 12-04-2013 06:11 AM |
VBA: Include Dynamic Sheet Name In Pivot Table Source Data | ibrahimaa | Excel Programming | 2 | 04-28-2012 12:27 AM |