hello guys and dolls, new to the forum so hopefully you can help me!
I have an existing pivot and would like to change the pivot fields via another sheet when selected. There are two pivot fields.
One called salesordno and second res_code
When they select the sales order no and resouce code and press the macro, the pivot table changes and bring the data forward.
I have the copy from the pivot working but not the change to the pivot fields?
Can you help?
I have some code I have written but do not know how to load so will post here?
Sheets("Look Up").Select
Set SO = Worksheets("Search").Range("D2")
Set RC = Worksheets("Search").Range("E2")
Set PT = Sheet4.PivotTables("PivotTable5")
For Each objDataField In PT.DataFields
objDataField.Orientation = xlHidden
Next
With PT
.AddDataField .PivotFields(Worksheets("Search").Range("D2").Value), SO, xlText
.AddDataField .PivotFields(Worksheets("Search").Range("E2").Value), RC, xlText
End With
PT.PivotCache.Refresh
Bookmarks