+ Reply to Thread
Results 1 to 3 of 3

Selecting PivotItems from another sheet

  1. #1
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    4,054

    Selecting PivotItems from another sheet

    I'll let you know up front that this is cross-posted here: http://www.mrexcel.com/forum/showthread.php?t=536608, because this forum wouldn't let me in earlier (Database Error, it said). No one has responded at the other posting, so I thought I'd try here.

    The problem: I need to alter a Pivot Table via VBA. What I need to do is change the PivotItems in the MOS2 PivotField; these are expenses by month, with the Months noted as "01","02"..."12". On another sheet, in another workbook, I have the list of months I want to see. I tried doing it by using the code below, but it fails with the message
    Please Login or Register  to view this content.
    Any help I can get on this is greatly appreciated. I've been searching for two days on the internet and can't find any help for this one, so you're my last hope.

    Thanks,
    John
    Please Login or Register  to view this content.
    Last edited by jomili; 03-17-2011 at 12:23 PM.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,243

    Re: Selecting PivotItems from another sheet

    Try putting in a .Text after the range.
    Please Login or Register  to view this content.
    If that doesn't work then try to use the index of PivotItems.

    Like
    If .PiviotItem(i).name = Vlookup.... then make visible = true.

    BTW - I've found you can't make all Visible = False as the Pivot Table will complain and code stops.

    hope this helps.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    4,054

    Re: Selecting PivotItems from another sheet

    MarvinP, you rock!

    Your first try did the trick, and it works flawlessly! I can't thank you enough. Now I can close two posts. Way cool! Thank you so much!

    John

+ 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