Share via

Pivot Table IFERROR

Anonymous
2011-05-17T02:10:00+00:00

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

Microsoft 365 and Office | Excel | For home | Windows

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.

0 comments No comments

Answer accepted by question author

Anonymous
2011-05-17T06:50:38+00:00

Yes

=IFERROR(GROSS/'T-SALE',0)

Was this answer helpful?

10+ people found this answer helpful.
0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Anonymous
    2011-05-17T12:51:22+00:00

    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?

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2011-05-17T12:09:05+00:00

    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

    Was this answer helpful?

    0 comments No comments