Hi guys
Sorry for using the word urgent. But I have limited time with a borrowed machine and really need to solve this issue asap.
I've written an procedure to automatically remove all existing data fields in a pivot table. The code works perfectly on a Windows PC but not on a Mac. Can you tell me what to do automatically remove data fields on a Mac?
The problem I'm having on a Mac is that Excel shuts down when attempting to execute the IsCalculated related lines. I"m using Excel for Mac 2011. Ver 14.1.0
The following is the code I'm using:
Sub RemoveOutput()
' Removes currenly viewed output fields
Dim pf As PivotField, PT As PivotTable
Dim strOldName, strOldCalc
Set PT = ActiveSheet.PivotTables(1)
PT.ManualUpdate = True
For Each pf In PT.DataFields
strOldName = pf.SourceName
With PT.PivotFields(strOldName)
If .IsCalculated Then
strOldCalc = .StandardFormula
.Delete
PT.CalculatedFields.Add strOldName, strOldCalc
Else
pf.Orientation = xlHidden
End If
End With
Next pf
PT.ManualUpdate = False
End Sub
Sorry for using the word urgent. But I have limited time with a borrowed machine and really need to solve this issue asap.
I've written an procedure to automatically remove all existing data fields in a pivot table. The code works perfectly on a Windows PC but not on a Mac. Can you tell me what to do automatically remove data fields on a Mac?
The problem I'm having on a Mac is that Excel shuts down when attempting to execute the IsCalculated related lines. I"m using Excel for Mac 2011. Ver 14.1.0
The following is the code I'm using:
Sub RemoveOutput()
' Removes currenly viewed output fields
Dim pf As PivotField, PT As PivotTable
Dim strOldName, strOldCalc
Set PT = ActiveSheet.PivotTables(1)
PT.ManualUpdate = True
For Each pf In PT.DataFields
strOldName = pf.SourceName
With PT.PivotFields(strOldName)
If .IsCalculated Then
strOldCalc = .StandardFormula
.Delete
PT.CalculatedFields.Add strOldName, strOldCalc
Else
pf.Orientation = xlHidden
End If
End With
Next pf
PT.ManualUpdate = False
End Sub