AdvSpreadGrid FormulaError


Suppressing the display of a formula if it's invalid for divide by zero.

We have a spreadsheet where we have a row of figures with a total at the end and we want to put a row of percentages below it eg

1   1 1    1 4

25 25 25 25

We have put formulae in the second row to calculate the percentages and that works fine UNLESS we have zeroes in the to row with a total of zero.

If that happens, we get the formulae displayed in the percentage cells.

To stop this happening, we trapped the error as below.

procedure TdmResult.FormulaError(ACol, ARow: Integer; S: string);


if (s = 'Division by zero') then ssResult.Ints[ACol,ARow] := 0;


This works fine save that it seems to replace the formula with zero.

This means that it remains zero even if data is later entered into the top row.

Our question is how can we get a blank or zero displayed in the percentage cell if the formula is invalid so that the formula remains and works properly if and when valid data is entered?

Best wishes


  1. I'm not sure what exact formula you use?
    2) If you want a division by zero to result as zero, have you considered implementing a custom function that has exactly this behavior?