+ Reply to Thread
Results 1 to 4 of 4

PivotFields problem

Hybrid View

  1. #1
    Tim
    Guest

    PivotFields problem

    Hi folks,

    I use the following code to get the items of PivotFields("Managers"). It
    works ok but not exactly what I am looking for. In the
    PivotFields("Managers"), I hide some of the items which I don’t want to show
    on the list. Could anyone show me the way to exclude the hidden items? Any
    help will be appreciated.

    Thanks in advance.

    Tim.

    Sub Macro1()

    Set nwSheet = Worksheets.Add
    nwSheet.Activate

    rw = 0
    For Each pvtitem In Sheets("Sheet1").PivotTables("PivotTable1") _
    .PivotFields("Managers").PivotItems
    rw = rw + 1
    nwSheet.Cells(rw, 1).Value = pvtitem.Name

    Next

    End Sub


  2. #2
    Tom Ogilvy
    Guest

    Re: PivotFields problem

    Sub Macro1()

    Set nwSheet = Worksheets.Add
    nwSheet.Activate

    rw = 0
    For Each pvtitem In Sheets("Sheet1").PivotTables("PivotTable1") _
    .PivotFields("Managers").PivotItems
    if pvtItem.Visible then
    rw = rw + 1
    nwSheet.Cells(rw, 1).Value = pvtitem.Name
    End if
    Next

    End Sub

    --
    Regards,
    Tom Ogilvy

    "Tim" <Tim@discussions.microsoft.com> wrote in message
    news:CB6B77BF-27A8-4D1B-8307-AB0A2C18609F@microsoft.com...
    > Hi folks,
    >
    > I use the following code to get the items of PivotFields("Managers"). It
    > works ok but not exactly what I am looking for. In the
    > PivotFields("Managers"), I hide some of the items which I don't want to

    show
    > on the list. Could anyone show me the way to exclude the hidden items?

    Any
    > help will be appreciated.
    >
    > Thanks in advance.
    >
    > Tim.
    >
    > Sub Macro1()
    >
    > Set nwSheet = Worksheets.Add
    > nwSheet.Activate
    >
    > rw = 0
    > For Each pvtitem In Sheets("Sheet1").PivotTables("PivotTable1") _
    > .PivotFields("Managers").PivotItems
    > rw = rw + 1
    > nwSheet.Cells(rw, 1).Value = pvtitem.Name
    >
    > Next
    >
    > End Sub
    >




  3. #3
    Tim
    Guest

    Re: PivotFields problem

    Hi Tom,

    The code only give me one manager which is not right. For example, I have
    nine managers. I hide 3 of them. I am expecting 6 manager on the new sheet.
    Could you help me?

    Thanks.

    Tim.

    "Tom Ogilvy" wrote:

    > Sub Macro1()
    >
    > Set nwSheet = Worksheets.Add
    > nwSheet.Activate
    >
    > rw = 0
    > For Each pvtitem In Sheets("Sheet1").PivotTables("PivotTable1") _
    > .PivotFields("Managers").PivotItems
    > if pvtItem.Visible then
    > rw = rw + 1
    > nwSheet.Cells(rw, 1).Value = pvtitem.Name
    > End if
    > Next
    >
    > End Sub
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    > "Tim" <Tim@discussions.microsoft.com> wrote in message
    > news:CB6B77BF-27A8-4D1B-8307-AB0A2C18609F@microsoft.com...
    > > Hi folks,
    > >
    > > I use the following code to get the items of PivotFields("Managers"). It
    > > works ok but not exactly what I am looking for. In the
    > > PivotFields("Managers"), I hide some of the items which I don't want to

    > show
    > > on the list. Could anyone show me the way to exclude the hidden items?

    > Any
    > > help will be appreciated.
    > >
    > > Thanks in advance.
    > >
    > > Tim.
    > >
    > > Sub Macro1()
    > >
    > > Set nwSheet = Worksheets.Add
    > > nwSheet.Activate
    > >
    > > rw = 0
    > > For Each pvtitem In Sheets("Sheet1").PivotTables("PivotTable1") _
    > > .PivotFields("Managers").PivotItems
    > > rw = rw + 1
    > > nwSheet.Cells(rw, 1).Value = pvtitem.Name
    > >
    > > Next
    > >
    > > End Sub
    > >

    >
    >
    >


  4. #4
    Tom Ogilvy
    Guest

    Re: PivotFields problem

    I would expect that to work. If you want to send me a copy of your workbook
    setup to so that if I run the macro I get incorrect results, then I will see
    if I can figure out what is going on.
    twogilvy@msn.com
    --
    Regards,
    Tom Ogilvy


    "Tim" <Tim@discussions.microsoft.com> wrote in message
    news:03A36A98-1190-4754-856A-08B1A15882F6@microsoft.com...
    > Hi Tom,
    >
    > The code only give me one manager which is not right. For example, I have
    > nine managers. I hide 3 of them. I am expecting 6 manager on the new

    sheet.
    > Could you help me?
    >
    > Thanks.
    >
    > Tim.
    >
    > "Tom Ogilvy" wrote:
    >
    > > Sub Macro1()
    > >
    > > Set nwSheet = Worksheets.Add
    > > nwSheet.Activate
    > >
    > > rw = 0
    > > For Each pvtitem In Sheets("Sheet1").PivotTables("PivotTable1") _
    > > .PivotFields("Managers").PivotItems
    > > if pvtItem.Visible then
    > > rw = rw + 1
    > > nwSheet.Cells(rw, 1).Value = pvtitem.Name
    > > End if
    > > Next
    > >
    > > End Sub
    > >
    > > --
    > > Regards,
    > > Tom Ogilvy
    > >
    > > "Tim" <Tim@discussions.microsoft.com> wrote in message
    > > news:CB6B77BF-27A8-4D1B-8307-AB0A2C18609F@microsoft.com...
    > > > Hi folks,
    > > >
    > > > I use the following code to get the items of PivotFields("Managers").

    It
    > > > works ok but not exactly what I am looking for. In the
    > > > PivotFields("Managers"), I hide some of the items which I don't want

    to
    > > show
    > > > on the list. Could anyone show me the way to exclude the hidden

    items?
    > > Any
    > > > help will be appreciated.
    > > >
    > > > Thanks in advance.
    > > >
    > > > Tim.
    > > >
    > > > Sub Macro1()
    > > >
    > > > Set nwSheet = Worksheets.Add
    > > > nwSheet.Activate
    > > >
    > > > rw = 0
    > > > For Each pvtitem In Sheets("Sheet1").PivotTables("PivotTable1") _
    > > > .PivotFields("Managers").PivotItems
    > > > rw = rw + 1
    > > > nwSheet.Cells(rw, 1).Value = pvtitem.Name
    > > >
    > > > Next
    > > >
    > > > End Sub
    > > >

    > >
    > >
    > >




+ 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