Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-22-2016, 12:30 PM
mbesspiata mbesspiata is offline Include and Exclude items through vba in pivot table Windows 7 64bit Include and Exclude items through vba in pivot table Office 2010 64bit
Advanced Beginner
Include and Exclude items through vba in pivot table
 
Join Date: Mar 2011
Location: Virginia
Posts: 57
mbesspiata is on a distinguished road
Question 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
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Include and Exclude items through vba in pivot table 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
Include and Exclude items through vba in pivot table Docx to PDF: Exclude heading from TOC but include in bookmarks Lebber Word 8 12-04-2013 06:11 AM
Include and Exclude items through vba in pivot table VBA: Include Dynamic Sheet Name In Pivot Table Source Data ibrahimaa Excel Programming 2 04-28-2012 12:27 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:05 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft