Lifterlady16
New Member
- Joined
- Aug 14, 2018
- Messages
- 6
Hey everyone! I recorded a macro to create a pivot table (amongst many many other functions) and everything works except for ONE item in the pivot table.
The line of code to include the pivot table "Months" above "Status" is not being read. I've putzed with it, and I cannot seem to figure out why....Hoping someone can solve the mystery for me?
Expected Outcome:
Filters - none
Columns - Region
Rows - Month (1st position), Status (2nd position)
Values - Month (count of)
The line of code to include the pivot table "Months" above "Status" is not being read. I've putzed with it, and I cannot seem to figure out why....Hoping someone can solve the mystery for me?
Expected Outcome:
Filters - none
Columns - Region
Rows - Month (1st position), Status (2nd position)
Values - Month (count of)
Code:
[FONT=Calibri][SIZE=3][COLOR=#000000]ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase,SourceData:= _[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] "Master!R1C1:R1048576C20", Version:=6).CreatePivotTableTableDestination:= _[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] "Sheet1!R3C1", TableName:="PivotTable2",DefaultVersion:=6[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] Sheets("Sheet1").Select[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] Cells(3, 1).Select[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] WithActiveSheet.PivotTables("PivotTable2").PivotFields("Status")[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] .Orientation =xlRowField[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] .Position = 1[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] End With[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] WithActiveSheet.PivotTables("PivotTable2").PivotFields("Month")[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] .Orientation =xlRowField[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] .Position = 2[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] End With[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] WithActiveSheet.PivotTables("PivotTable2").PivotFields("Region")[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] .Orientation =xlColumnField[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] .Position = 1[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] End With[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] WithActiveSheet.PivotTables("PivotTable2").PivotFields("Month")[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] .Orientation = xlRowField[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] .Position = 1[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] End With[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] ActiveSheet.PivotTables("PivotTable2").AddDataFieldActiveSheet.PivotTables( _[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] "PivotTable2").PivotFields("Month"), "Count ofMonth", xlCount[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] Sheets("Sheet1").Select[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] Sheets("Sheet1").Name= "Data.Charts"[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] Range("A19").Select[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] Sheets("Master").Select[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]End Sub[/COLOR][/SIZE][/FONT]
[Code]