While you cannot do this in Excel, this is possible in Resolver One (although this is still a rather strange thing).
This is a spreadsheet that allows you to define custom functions in Python, which you can then call from a cell formula in a grid.
As an example of what you are asking, you can define the safeDivide function, which (instead of raising ZeroDivisionError ) told you about the problem by coloring the denominator cell and placing the error message next to This. You can define it as follows:
def safeDivide(numerator, cellRange): if not isinstance(cellRange, CellRange): raise ValueError('denominator must be a cell range') denominator = cellRange.Value if denominator == 0: cell = cellRange.TopLeft cell.BackColor = Color.Red cell.Offset(1, 0).Value = 'Tried to divide by zero' return 0 return numerator / denominator
There is an additional wrinkle: the functions that the transferred cells transmit simply transmit the cell value, so in order to get around this, we insist on transmitting a single-network cellular range for the denominator.
If you are trying to do unusual things with spreadsheets that don’t quite fit into Excel, or you are interested in using Python to work with the data in your spreadsheets, you should take a look at Resolver One.
source share