+ Reply to Thread
Results 1 to 3 of 3

Hide PivotItems by Index

Hybrid View

  1. #1
    Registered User
    Join Date
    07-29-2007
    Posts
    24

    Hide PivotItems by Index

    Hi,

    I have written some code that creates a date-frequency pivot table. I use the grouping feature to group the dates into groups of 7, starting on a particular Sunday defined by the user (Sunday's are the start of our working week). This works fine, but I need to hide the first, second to last, and last PivotItem in order to plot a legible graph. I have searched the web and come up the code below; however, it keeps coming up with the error:

    "Unable to set the visible property of the PivotItem class".

    Can anyone help?

        With ActiveSheet.PivotTables("PivotTable1").PivotFields("Started Date")
          Dim i As Variant
          Dim last As Variant
          last = .PivotItems.Count
          For Each i In Array(1, last, last-1)
             .PivotItems(i).Visible = False
          Next i
          .PivotItems("(blank)").Visible = False
          End With

  2. #2
    Registered User
    Join Date
    07-29-2007
    Posts
    24

    Re: Hide PivotItems by Index

    Just nudging this back to the top.

  3. #3
    Registered User
    Join Date
    05-19-2011
    Location
    Glasgow
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    1

    Re: Hide PivotItems by Index

    It's because it's a date, use

    .NumberFormat = "dd/mm/yyyy"

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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