Explanation

The FORMULATEXT is fully automatic.

Seethis pagefor a full explanation.

you’re free to use FORMULATEXT to extract the formula as text from a cell.

Excel FORMULATEXT function

If you use FORMULATEXT on a cell that doesn’t contain a formula, it returns #N/A.

IFERROR is an elegant way to trap and manage errors without using more complicated nested IF statements.

When a cell contains a formula ISFORMULA will return TRUE regardless of the formula’s output or error conditions.

Excel IFERROR function

Excel ISFORMULA function