Solved

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

Posted on 2013-01-24
3
588 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

895 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

17 Experts available now in Live!

Get 1:1 Help Now