Solved

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

Posted on 2013-01-24
3
597 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

737 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