+ Reply to Thread
Results 1 to 6 of 6

Problem adding pagefield to a pivot table using VBA

  1. #1
    Forum Contributor
    Join Date
    06-19-2014
    Location
    Toronto, Canada
    MS-Off Ver
    Office365
    Posts
    273

    Problem adding pagefield to a pivot table using VBA

    Hello,

    I encountered a weird thing using the below codes:

    pt.AddFields PageFields:="Description"
    pt.AddFields RowFields:=Array("Date2", "Description2")

    after I ran the first line, the PT did add the page field, but after I ran the second line, the pagefield was removed and the two rowfields were added. Same thing happened when I changed the order of the two lines (adding rowfields first then pagefields, this time, the rowfields were removed and only the pagefield remains)


    does anyone know how to fix this?

    thanks!

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: Problem adding pagefield to a pivot table using VBA

    Perhaps posting your entire code ( with code tags) and your sheet would help us help you?

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,431

    Re: Problem adding pagefield to a pivot table using VBA

    The addFields adds Row. Column and Page fields all at one go.

    If you then use another .AddFields instruction it will replace all 3 with information provided. If you don't provide information for any one of them the field will be removed.
    Cheers
    Andy
    www.andypope.info

  4. #4
    Forum Contributor
    Join Date
    06-19-2014
    Location
    Toronto, Canada
    MS-Off Ver
    Office365
    Posts
    273

    Re: Problem adding pagefield to a pivot table using VBA

    I had to code this with recorded codes and it works. would you please let me know how to get around this so both can stay?

    thanks so much for your time!

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,431

    Re: Problem adding pagefield to a pivot table using VBA

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    06-19-2014
    Location
    Toronto, Canada
    MS-Off Ver
    Office365
    Posts
    273

    Re: Problem adding pagefield to a pivot table using VBA

    thanks so much for your help!!

+ 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. Replies: 7
    Last Post: 02-27-2017, 07:41 AM
  2. Replies: 6
    Last Post: 01-24-2017, 06:56 PM
  3. Adding a calculated item to a pivot table - problem encountered
    By Jimmy Newman in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 08-23-2012, 08:35 AM
  4. Pivot Table pagefield returns wrong data when changed with vba
    By kuraitori in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-05-2010, 03:32 PM
  5. Replies: 0
    Last Post: 07-17-2008, 01:19 PM
  6. Replies: 0
    Last Post: 08-09-2006, 03:40 AM
  7. [SOLVED] Pivot Pagefield multi-select? (Excel 2003)
    By NorTor in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-13-2006, 10:35 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