ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   PivotTable Field Selection (https://www.excelbanter.com/excel-programming/304877-pivottable-field-selection.html)

Reney Langlois

PivotTable Field Selection
 
Hi,
I have a pivot table with three fields located in
the "page" area. When I open the workbook and select the
worksheet with the pivottable, all three fields default
to "(All)". I'd like to write some code that after
updating the pivottable, also selects one of the specific
options behind one of the fields so the reader doesn't
have to each time. I know how to refresh the pivot
programmatically. I tried recording the actions of
selecting a value from one of these fields and using this
code in my macro but it gives an error. Below is the
recorded macro code.

ActiveSheet.PivotTables("PivotTable1").PivotFields ("COPQ
Ind").CurrentPage = "1"

Thanks much,

Reney Langlois

Tom Ogilvy

PivotTable Field Selection
 
With ActiveSheet.PivotTables("PivotTable1").PivotFields ("COPQ Ind")
for each itm in .Items
if itm.Value = 1 then
.CurrentPage = itm.Value
exit for
end if
Next
End if

Has worked for me in this situation.

--
Regards,
Tom Ogilvy


"Reney Langlois" wrote in message
...
Hi,
I have a pivot table with three fields located in
the "page" area. When I open the workbook and select the
worksheet with the pivottable, all three fields default
to "(All)". I'd like to write some code that after
updating the pivottable, also selects one of the specific
options behind one of the fields so the reader doesn't
have to each time. I know how to refresh the pivot
programmatically. I tried recording the actions of
selecting a value from one of these fields and using this
code in my macro but it gives an error. Below is the
recorded macro code.

ActiveSheet.PivotTables("PivotTable1").PivotFields ("COPQ
Ind").CurrentPage = "1"

Thanks much,

Reney Langlois





All times are GMT +1. The time now is 04:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com