ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Pivot Table with variable # of columns (https://www.excelbanter.com/excel-programming/386694-pivot-table-variable-columns.html)

samlyon

Pivot Table with variable # of columns
 
I am trying to create a pivot table using VBA and will have a different
amount of data columns each month. In January, for example, i will only have
January, but in February, i will have january and February and so forth. So
far, i haven't found a way to do it.

Any help would be greatly appreciated.
Thanks!

Debra Dalgleish

Pivot Table with variable # of columns
 
You could use the address of the current region, e.g.:

Dim rng As Range

Set rng = Worksheets("Data").Range("A1").CurrentRegion
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, _
SourceData:=rng.Address).CreatePivotTable _
TableDestination:="", TableName:="PivotTable1"

samlyon wrote:
I am trying to create a pivot table using VBA and will have a different
amount of data columns each month. In January, for example, i will only have
January, but in February, i will have january and February and so forth. So
far, i haven't found a way to do it.

Any help would be greatly appreciated.
Thanks!



--
Debra Dalgleish
Contextures
http://www.contextures.com/tiptech.html



All times are GMT +1. The time now is 08:37 AM.

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