removing #DIV/0! in VBA in a calculated field in a pivot table

G

Guest

I have written a program in VBA that creates pivot tables. There is a
calculated field which creates a percentage based on a division between sums
of two of the fields in the pivot table. The denominator occasionally shows
up as a "0", causing a #DIV/0! to appear. I have set the null string to a
blank, but since the range that creates the sum has a formula in it, the sum
still shows up as a "0". How can I code this to remove the #DIV/0!?

Thanks
 
G

Guest

Without and code I will have to be generic but this should be close...

With ActiveSheet.PivotTables("PivotTable1")
.DisplayErrorString = True
.ErrorString = "0"
End With

instead of #DIV/0!it will show 0 as the errorstring...

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top