A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Yes
=IFERROR(GROSS/'T-SALE',0)
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Can the IFERROR Function be used on a Pivot Table Calculated Item. I have a calculate Item that needs to be zero on #Div/0. The VBA I used to create the Calculated Item is:
'Add Gross Percentage Sale
With PT
.CalculatedFields.Add "Gr%Sls", _
"=GROSS/'T-SALE'", True
.PivotFields("Gr%Sls").Orientation = _
xlDataField
End With
'Set Percentage Format
With PT
.PivotFields("Sum of Gr%Sls") _
.NumberFormat = "0.00%"
End With
When I get the #Div/0 it prevents from getting the Total of this Calculated Field, instead I get the error #Div/0
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
Answer accepted by question author
Yes
=IFERROR(GROSS/'T-SALE',0)
I would have changed your code like this:
With PT
.CalculatedFields.Add "Gr%Sls", _
"=IFERROR(GROSS/'T-SALE',0)", True
.PivotFields("Gr%Sls").Orientation = _
xlDataField
End With
'Set Percentage Format
With PT
.PivotFields("Sum of Gr%Sls") _
.NumberFormat = "0.00%"
End With
--
Does that not work?
Where exactly should I put this statement. If I use the code you sent I get errors. I tried adding it in the With statement and adding after the End With. Both errored out