Good Evening,
A few months ago I started learning VBA and have had a great time learning. Today I need some assistance on my pivot table building.
My macro works fine when I use it, Excel 2013, but when an associate did a quick test it errored out on them, he uses Excel 2007. The associate was in a rush but I was able to do a quick debug and it yellowed the section in my code that starts building the pivot table (highlighted in red). My macro does a lot of pre work to the data before building the pivot table so the below code is about 1/3 down in my macro code:
'Create Tab For Pivot View'
Sheets.Add After:=ActiveSheet
Sheets("Sheet2").Select
Sheets("Sheet2").name = "Pivot"
'Build Pivot Table'
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Data!R1C1:R1048576C14", Version:=xlPivotTableVersion15).CreatePivotTable _
TableDestination:="Pivot!R5C5", TableName:="PivotTable1", DefaultVersion _
:=xlPivotTableVersion15
Sheets("Pivot").Select
Cells(5, 5).Select
ActiveSheet.PivotTables("PivotTable1").RowAxisLayout xlTabularRow
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Unit Manager")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Associate Manager")
.Orientation = xlRowField
.Position = 2
End With
I used the macro recorder to record the above code. Am I having issues with other people running my macro because I don't have all that other code I see in peoples macros like:
Dim sht As Worksheet
Dim pvtCache As PivotCache
Dim pvt As PivotTable
Dim StartPvt As String
Dim SrcData As String
Is all the above code necessary? If it helps my data set is column A - M, and 200 rows. Thx for any help you can provide.
Bookmarks