PivotTable VBA help needed

J

JohnUK

Hi I am really stuck with this one and spent hours trying to work it out but
without success
I am trying to get a pivot table field to return/Copy a name from a cell on
a sheet, For example in the ROW section of the Pivot Table there could be up
to a hundred questions to select from (which could change from week to week)
and as you can imagine would be a nightmare to keep changing, especially as
there is going to be 50 sheets/tabs to change in the workbook.
I copied and tried to adapt this code that I found earlier without success:
Sub Macro2()
Dim ID As String
Dim PT As PivotTable
Dim PF As PivotField
Dim PI As PivotItem
ID = ActiveSheet.Range("question_title")
On Error Resume Next
For Each PT In ActiveSheet.PivotTables
Set PF = PT.PivotFields.question_title
Set PI = Nothing
Set PI = PF.PivotFields(ID)
Next
On Error GoTo 0
End Sub

I named the cell with a Range Name of question_title, but I presume I will
need to have a different name for each tab or can I just specify a cell?

Help as usual greatly appreciated
John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top