ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy Columns from Excel Pivot Table in a Macro (https://www.excelbanter.com/excel-programming/377770-copy-columns-excel-pivot-table-macro.html)

Dave

Copy Columns from Excel Pivot Table in a Macro
 
Does anyone know how to select a column from a pivot table from a macro? I
would like to select a column that corresponds to an attribute of the
horizontal fields. For example, I would like to specify a year as 2006 then
copy the year no matter which column the data for 2006 is located.

Bernie Deitrick

Copy Columns from Excel Pivot Table in a Macro
 
Dave,

Something along the lines of

ActiveSheet.PivotTables("PivotTable1").PivotSelect "", xlDataAndLabel, True
Selection.Find(What:="2006", LookAt:=xlWhole).EntireColumn.Copy

The specific "What" to look for depends on your actual year values.

HTH,
Bernie
MS Excel MVP


"Dave" wrote in message
...
Does anyone know how to select a column from a pivot table from a macro? I
would like to select a column that corresponds to an attribute of the
horizontal fields. For example, I would like to specify a year as 2006 then
copy the year no matter which column the data for 2006 is located.





All times are GMT +1. The time now is 12:31 PM.

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