this is about all I can think of to try if you can't alter the data source
Private Sub CommandButton2_Click()
Dim PT As PivotTable
Dim pf As PivotField
Dim Pi As PivotItem
Dim lCalc As XlCalculation
Dim wsFTE As Worksheet
With Application
.ScreenUpdating = False
.EnableEvents = False
lCalc = .Calculation
.Calculation = xlCalculationManual
.DisplayStatusBar = False
End With
Set wsFTE = ThisWorkbook.Sheets("Year-to-Date Paid FTEs")
With wsFTE
.Range("B3:D200").ClearContents
.Range("G3:I10").ClearContents
End With
Workbooks.Open _
"\\OurServer\SHARE10098\Budget\SOBUDGET\12MFR\Expense_Dtl_Reports\PAID_FTES_BR1112.xlsx", ReadOnly:=True, UpdateLinks:=True
Set PT = ActiveSheet.PivotTables(1)
With PT
.ManualUpdate = True
.RowGrand = False
.ColumnGrand = False
With .PivotFields("Department")
.AutoSort xlManual, .SourceName
.Orientation = xlRowField
.Position = 1
.Subtotals = Array(False, False, False, False, False, False, False, False, False, False, False, False)
On Error Resume Next
For Each Pi In .PivotItems
If Pi.Name = "510" Or Pi.Name = "511" Or Pi.Name = "513" Or Pi.Name = "514" _
Or Pi.Name = "516" Or Pi.Name = "517" Then
If Not Pi.Visible Then Pi.Visible = True
Else
If Pi.Visible Then Pi.Visible = False
End If
Next Pi
On Error GoTo 0
.AutoSort xlAscending, .SourceName
End With
With .PivotFields("PAY_END_DT")
.Orientation = xlPageField
.Position = 12
End With
.RepeatAllLabels xlRepeatLabels
.ManualUpdate = False
With .TableRange1
.Offset(2, 0).Resize(.Rows.Count - 2, .Columns.Count).Copy wsFTE.Range("B3")
End With
.ManualUpdate = True
On Error Resume Next
With .PivotFields("Posn Func")
.AutoSort xlManual, .SourceName
For Each Pi In .PivotItems
Select Case Pi.Name
Case "0025", "0058", "0059", "0109", "0110"
Case Else
If Pi.Visible Then Pi.Visible = False
End Select
Next Pi
On Error GoTo 0
.AutoSort xlAscending, .SourceName
End With
.ManualUpdate = False
With .TableRange1
.Offset(2, 0).Resize(.Rows.Count - 2, .Columns.Count).Copy wsFTE.Range("G3")
End With
End With
Workbooks("PAID_FTES_BR1112.xlsx").Close SaveChanges:=False
With Application
.DisplayStatusBar = True
.EnableEvents = True
.Calculation = lCalc
.ScreenUpdating = True
End With
End Sub
Bookmarks