OK, I've been digging through a lot of resources, but I can't find any clues on how to achieve this. I've dug through the object model but none of the properties or methods appear to give me what I need.
I want to get the row data of the selected row. I don't want to extract the data onto a new sheet, I just want to get the Row Label of the active row. I then put that row data into a sheet that displays the details in a better format than just the extracted method.
To simplify the example, my pivot has:
- Row Labels: Case_Name, Case_Ref (1:1 relationship)
- Column Labels: Status
- Values: Count of Calls
Ideally, I'd like to have Case_Ref hidden from view in the Pivot, but it is the key I need to extract for the next step.
I want the user to select one item (row) in the pivot, then press my button and have the macro return the Case_Ref of the selected row.
My (unsuccessful) code so far looks like this:
Sub Pivot_Detail_By_Case__Customer_Contacts_By_Case()
'CCBC = Customer Contacts By Case
Set CCBC_PivotTable = Worksheets("Customer contacts by case").PivotTables(1)
HeaderRow = CCBC_PivotTable.RowRange.Row
RowCount = CCBC_PivotTable.RowRange.Count
'Confirm limits of row range
'Range(Cells(HeaderRow + 1, 1), Cells(HeaderRow + RowCount - 2, 1)).Select
PivotDataStartRow = HeaderRow + 1
PivotDataEndRow = HeaderRow + RowCount - 2
If ActiveCell.Row >= PivotDataStartRow And ActiveCell.Row <= PivotDataEndRow Then
ItemNumber = ActiveCell.Row - PivotDataStartRow
'SelectedField = CCBC_PivotTable.DataPivotField.PivotItems(ItemNumer)
'pvt_InnerDetail = CCBC_PivotTable.InnerDetail
'SelectedField = CCBC_PivotTable.RowFields("Case_Ref")
End If
End Sub
The ItemNumber appears to work, but how do I get the Case_Ref from there?
Thanks for your help.