Google-sheets – How to Auto Calculate the Missing Column

google sheets

Let's say you have two columns that are related to each other by a simple formula. Perhaps Column A has monthly expenses and Column B has the expenses annualized. Now, for some rows you may want to enter the annual expense and have the monthly expense calculated, and other rows you may want to enter monthly expenses and have the spreadsheet calculate the annual expenses. One solution I have is as follows:

Column A Formula

=IF(NOT(ISBLANK(B3)),B3/12,)

Column B Formula

=IF(NOT(ISBLANK(A3)),A3*12,)

Ignore for the moment that I should probably be using ARRAYFORMULA which I only just discovered in searching for an answer to this question. The above two formulas will form a circular dependency.

Best Answer

=IF(NOT(ISBLANK(B3)),B3/12,) and =IF(NOT(ISBLANK(A3)),A3*12,) will not work the in the manner you are thinking because, initially both cells, A3 and B3 are blank, therefore both forumlas will try to calculate a value which will make them non-blank; which means the formulas should not calculate a value, which means, …

Instead of ISBLANK() use ISFORMULA(). This will test the content of the target cell for a formula, not simply whether the displayed content is blank. Entering a literal numeric value:

=IF(NOT(ISFORMULA(B3)),B3/12,)

and

=IF(NOT(ISFORMULA(A3)),A3*12,)

Note that your manually entered values must not be entered as a forumla. That is, enter your expense values as their simple numeric values

2.54

and do not prefix them with and equal (=) character—an equal prefix signifies a formula.

=2.54

This will cause the NOT(ISFORMULA(…) check to fail and no value will be calculated.