Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4009564
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:53:36+00:00 2026-05-20T08:53:36+00:00

When comparing: PivotTable.PivotFields(field1).PivotItems to: PivotTable.PivotFields(field2).PivotItems The ordinal positions of the items when consumed from

  • 0

When comparing:
PivotTable.PivotFields(“field1”).PivotItems
to:
PivotTable.PivotFields(“field2”).PivotItems

The ordinal positions of the items when consumed from VBA do not match that which is displayed on the screen.

Note that in the code below, I have explicitly set both PivotFields to visible (xlColumnField), and set the position of one of them to 1.

On the screen, the position of the PivotItems within each of the two PivotFields lines up accordingly (obviously). But when in this state, you examine the items through VBA, the ordinal position within each collection, as well as the .Position Property, are different than what is displayed on the screen.

Is there a way to properly access these so I can find proper matches between the individual PivotItems across multiple PivotFields? (Or some other way of going about it?)

Sub debugPivotTableFieldData(pt As PivotTable)
    Dim aPivotField As PivotField
    Dim aPivotItem As PivotItem
    Dim iField As Integer

    Debug.Print pt.PivotFields("Airport").Orientation
    Debug.Print pt.PivotFields("Name").Orientation

    pt.PivotFields("Airport").Orientation = XlPivotFieldOrientation.xlColumnField
    pt.PivotFields("Name").Orientation = XlPivotFieldOrientation.xlColumnField
    pt.PivotFields("Airport").Position = 1

    Debug.Print "DEBUG PIVOT TABLE: " & pt.Name
    For iField = 1 To pt.PivotFields("Airport").PivotItems.Count
        Debug.Print pt.PivotFields("Airport").PivotItems(iField) & " - " & pt.PivotFields("Airport").PivotItems(iField).Position
    Next
    For iField = 1 To pt.PivotFields("Name").PivotItems.Count
        Debug.Print pt.PivotFields("Name").PivotItems(iField) & " - " & pt.PivotFields("Name").PivotItems(iField).Position
    Next
    For iField = 1 To pt.PivotFields("Airport").PivotItems.Count
        Debug.Print pt.PivotFields("Airport").PivotItems(iField) & " - " & pt.PivotFields("Name").PivotItems(iField)
    Next
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T08:53:36+00:00Added an answer on May 20, 2026 at 8:53 am

    I’m 95% certain this is just the way it is. I think the ordinal position of the items in the collection has no relation whatsoever to what is displayed on the screen, or what the value of .Position is for each element.

    So to properly set the column positions for the pivot items in two pivot fields at once, I filled a Scripting.Dictionary with the distinct values (of the two fields) from the PivotTable.PivotCache.Recordset….then, iterate on the dictionary items, and you can access the the PivotItems in each pivot field by name and set their .Position that way so they have matching sorts.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When comparing enums that come from different sources such as those of the following
I have trouble comparing 2 double in Excel VBA suppose that I have the
Comparing version numbers as strings is not so easy... 1.0.0.9 > 1.0.0.10, but it's
When comparing Île and Ile, C# does not consider these to be to be
When comparing two different algorithm implementations (thus, not caring for their absolute, but only
I am comparing two strings using following code string1.Contains(string2) but i am not getting
Im having a problem comparing dates in a database to a week from now
I'm comparing these two tools. The impression I have is: Inno Setup does not
I'm comparing some currency values in DUnit but it is not working at all
Comparing two sql values that are almost the same. I know this is simple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.