Solved

Excel VB.net Add-in  Find Pivot header based on pivot cell

Posted on 2013-01-24
3
583 Views
Last Modified: 2013-02-03
Hi

In the following pivot what VBA code would I use to find the header (eg Goal, Status, Task) based on the cell I am in. The pivot can change so I need to be able to do this dynamically.

I use the following code to get the pivot cell to the left:

    Function Get_Pivot_Cell_to_Left() As String
        Try
            'Gets the pivot cell value to left even where label is blank
            Dim pCell As Excel.PivotCell
            'pCell = Globals.ThisAddIn.Application.ActiveCell.PivotCell
            pCell = Globals.ThisAddIn.Application.ActiveCell.PivotCell
            If pCell.PivotField.Position > 1 Then
                Get_Pivot_Cell_to_Left = pCell.PivotRowLine.PivotLineCells(pCell.PivotField.Position - 1).PivotItem.Caption
            End If

        Catch ex As Exception
            MsgBox("Problem getting Task data " & ex.Message)
            Get_Pivot_Cell_to_Left = ""
        End Try
    End Function

1
0
Comment
Question by:murbro
  • 2
3 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 38813467
Does this code return you header of the left side?
0
 

Accepted Solution

by:
murbro earned 0 total points
ID: 38813522
Hi

Yes it does.

I can get anu of the three headers using
Get_Pivot_Field = pCell.PivotField.Name

but I am still struggling to get the two top one "Project:Site", and the other
0
 

Author Closing Comment

by:murbro
ID: 38848276
this post answered the original question
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now