montanaheather
New Member
- Joined
- Oct 31, 2011
- Messages
- 25
Hello,
I am trying to write a macro for a pivot table that will work on all sheets in my workbook. Each sheet represents a different month, and the pivot table is meant to summarize budget information for each month. Below is the code. Please help!
Sub BudgetMacro1()
'
' BudgetMacro1 Macro
'
'
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Sheet1!R1C1:R35C5", Version:=xlPivotTableVersion12).CreatePivotTable _
TableDestination:="Sheet1!R4C9", TableName:="PivotTable1", DefaultVersion _
:=xlPivotTableVersion12
Sheets("Sheet1").Select
Cells(4, 9).Select
ActiveWorkbook.ShowPivotTableFieldList = True
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Date")
.Orientation = xlRowField
.Position = 1
End With
End Sub
I am trying to write a macro for a pivot table that will work on all sheets in my workbook. Each sheet represents a different month, and the pivot table is meant to summarize budget information for each month. Below is the code. Please help!
Sub BudgetMacro1()
'
' BudgetMacro1 Macro
'
'
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Sheet1!R1C1:R35C5", Version:=xlPivotTableVersion12).CreatePivotTable _
TableDestination:="Sheet1!R4C9", TableName:="PivotTable1", DefaultVersion _
:=xlPivotTableVersion12
Sheets("Sheet1").Select
Cells(4, 9).Select
ActiveWorkbook.ShowPivotTableFieldList = True
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Date")
.Orientation = xlRowField
.Position = 1
End With
End Sub
Last edited: