Is it possible to add variables to a pivot datafield name?

W

wesley24

Hello,

I am tring to get the user to input the abbreviation for the month
they would like to pivot on, assign it to a variable, and use it to
identify which datafield to select.

* PivMonth = InputBox(prompt:="Please enter the abbreviation for the
month you would like to see in your pivot table. (ex. Dec)")

Set WIPcache =
WB.PivotCaches.Add(SourceType:=xlDatabase, SourceData:=PivRng.Address)
Set WIPpiv =
WIPcache.CreatePivotTable(Tabledestination:=Piv.Range("A3"),
Tablename:="PivWIP")

With WIPpiv.PivotFields("Program ID")
.Orientation = xlRowField
End With

* ActiveSheet.PivotTables("PivWIP").AddDataField
ActiveSheet.PivotTables("PivWIP" _
).PivotFields(PivMonth & "USD"), xlSum

Thank you,
Wes
 

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