Murray Brown
asked on
Excel VB.net Add-in Find Pivot header based on pivot cell
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.Applicat ion.Active Cell.Pivot Cell
pCell = Globals.ThisAddIn.Applicat ion.Active Cell.Pivot Cell
If pCell.PivotField.Position > 1 Then
Get_Pivot_Cell_to_Left = pCell.PivotRowLine.PivotLi neCells(pC ell.PivotF ield.Posit ion - 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
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.Applicat
pCell = Globals.ThisAddIn.Applicat
If pCell.PivotField.Position > 1 Then
Get_Pivot_Cell_to_Left = pCell.PivotRowLine.PivotLi
End If
Catch ex As Exception
MsgBox("Problem getting Task data " & ex.Message)
Get_Pivot_Cell_to_Left = ""
End Try
End Function
Does this code return you header of the left side?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
this post answered the original question