Pivot Table and Cell Reference

cmrluvitlevit

New Member
Joined
Oct 9, 2007
Messages
41
I have a pivot table that has all of my project numbers and current costs associated with cost codes. I want to create a code that will take the project number in cell F1 and this will go to the 'Project_ID' in the Pivot Table, then filter the pivot table on the Project_ID.

It must also refresh the pivot table to external data through the refresh button.

I have been struggling with this for a day now and could use some help.
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
The following code does not refresh the table. It will put the value in F1 as Project_ID; however none of the values in the Pivot Table change. It does not do anything.


Sub UpdatePivotTable()
Dim PT As PivotTable
Set PT = Sheets("CTC Financial").PivotTables("PivotTable2")
PT.PivotFields("Project_ID").CurrentPage = Sheets("CTC Financial").Range("F1").Value
Set PT = Nothing

End Sub
 
Upvote 0
This is as far as I have gotten with the code:

Sub UpdatePivotTable()
Range("E4").Select
Selection.Copy
Sheets("CTC Financial").Select
Range("F1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A1").Select

Dim PT As PivotTable
Set PT = Sheets("CTC Financial").PivotTables("PivotTable2")
PT.PivotFields("Project_ID").CurrentPage = Sheets("CTC Financial").Range("F1").Value
Set PT = Nothing
PT.RefreshTable
End Sub

I am getting an error with "Unable to get pivot table properties of the worksheet class".
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,728
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top