+ Reply to Thread
Results 1 to 3 of 3

Select Pivot Field Item

  1. #1
    Registered User
    Join Date
    07-26-2012
    Location
    The Netherlands
    MS-Off Ver
    Excel 2003
    Posts
    21

    Select Pivot Field Item

    In Excel 2010 when I use the macro recorder to select a pivot item in field Name I get a code (shown below). If I run this code it works. However if I do the same thing for a field called Date the macro doesn't work when I run it. Instead I get the following error: "Run-time error '1004' Unable to get the PivotItems property of the PivotField class"


    I've been spending far too much time on this and it's driving me mad. Could someone tell me why the Name field macro works but the Date field macro doesn't?

    Name code
    With ActiveSheet.PivotTables("PT_MME_Detailed").PivotFields("Name")
    .PivotItems("John.Doe").Visible = False
    End With

    Date code
    With ActiveSheet.PivotTables("PT_MME_Detailed").PivotFields("Date")
    .PivotItems("1/3/2013").Visible = False
    End With
    Last edited by ShareTheGlobe; 10-30-2013 at 05:14 AM.

  2. #2
    Registered User
    Join Date
    05-11-2011
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003-13
    Posts
    2

    Re: Select Pivot Field Item

    You have to ensure that the date displayed in Excel and the date actually read in VBA are the same. The format really makes a difference here.

    See this example

    Please Login or Register  to view this content.
    Also if it is the only item in the pivot then you cannot hide it.

  3. #3
    Registered User
    Join Date
    07-26-2012
    Location
    The Netherlands
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Select Pivot Field Item

    Thanks for your answer!

    I've been trying to recreate your code in a new document but I can't get it to work.

    Could you please upload your excel document so I can use that as reference?

    Thanks again.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Hide Pivot Field Item with VBA
    By matt4003 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-25-2013, 03:31 PM
  2. Replies: 1
    Last Post: 12-21-2012, 05:40 AM
  3. pivot page field item criteria.
    By cherrynich in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-24-2006, 11:25 AM
  4. [SOLVED] Pivot field dropping one item
    By Sharon in forum Excel General
    Replies: 1
    Last Post: 03-31-2006, 01:35 AM
  5. Calculated Field/Item in a Pivot
    By Matt D Francis in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 03-01-2006, 05:10 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1