+ Reply to Thread
Results 1 to 10 of 10

How to find pivot table field values of active cell?

  1. #1
    Registered User
    Join Date
    12-02-2010
    Location
    France
    MS-Off Ver
    Excel 2007
    Posts
    3

    How to find pivot table field values of active cell?

    In a pivot table, how do I pass the selected cell field values (ie the values of row & column data for the selected cell) to VBA? I just can't find the correct syntax... I think it's something like

    ActiveCell.PivotField("fieldname").value but that doesn't work.

    (In Access, I can use Me.PivotTable.ActiveObject.Cell.Recordset.Fields("fieldname").Value)

    Have looked through VBA's locals window without success.

    Thanks in advance.
    Last edited by Iain21; 12-02-2010 at 09:14 AM.

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: How to find pivot table field values of active cell?

    Could you give a specific example? I'm not quite following what it is you want returned.
    Remember what the dormouse said
    Feed your head

  3. #3
    Registered User
    Join Date
    12-02-2010
    Location
    France
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: How to find pivot table field values of active cell?

    Example in attached image; if I click on cell L6, I want to find the Supplier, ItemID and ItemType values corresponding to that cell, in VBA.
    Attached Images Attached Images

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: How to find pivot table field values of active cell?

    In what format do you want them returned? You basically want the Name property of the Row or ColumnItems:
    Please Login or Register  to view this content.
    for the supplier for example.

  5. #5
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: How to find pivot table field values of active cell?

    Quote Originally Posted by Iain21 View Post
    Example in attached image; if I click on cell L6, I want to find the Supplier, ItemID and ItemType values corresponding to that cell, in VBA.
    why not to add respective columns to pivot table?

  6. #6
    Registered User
    Join Date
    12-02-2010
    Location
    France
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: How to find pivot table field values of active cell?

    romperstomper - thank you very much, simple when you know how! I see the ColumnItems/RowItems number will have to be "hard coded" into the VBA, but this solution will work fine for me as I don't intend to change the layout of the pivot table. I thought I could reference the values using its name - eg "ItemID" as I could in Access, but perhaps this is not possible. In any case it'll work for me, so thanks.

  7. #7
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: How to find pivot table field values of active cell?

    You could loop through each one and check its parent field name if you wanted.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

  8. #8
    Registered User
    Join Date
    05-12-2004
    Posts
    10

    Re: How to find pivot table field values of active cell?

    Hi this query seems to be un answered or the solution provided is not working. Can someone help on this please?

  9. #9
    Registered User
    Join Date
    05-12-2004
    Posts
    10

    Question Re: How to find pivot table field values of active cell?

    This remains unanswered or the solution provided does not work. Can someone help here

  10. #10
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: How to find pivot table field values of active cell?

    Hi vsm & Welcome to the Forum, unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.
    HTH
    Regards, Jeff

+ 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