I have a macro that creates a new pivot table and the pivot table will then always have new name so I have renamed my pivot table to my sheet name, "Pivot", and now when I try to hide a column I am getting a run time error '1004': Unable to set the orientation property of the PivotField class.
Or would it work better to name the pivot table while I am creating it, what would that code look like?
VBA Code:
Dim ws As Worksheet
Dim pts As PivotTables
Dim pt As PivotTable
Set ws = ActiveSheet
Set pts = ActiveSheet.PivotTables
If pts.Count < 1 Then Exit Sub
Set pt = ws.PivotTables(1)
pt.Name = ws.Name
ActiveSheet.PivotTables("Pivot").PivotFields("Future").Orientation = xlHidden
Or would it work better to name the pivot table while I am creating it, what would that code look like?