Macro to convert formulas to "IF(ISERROR)
Posted by Dwight on November 07, 2001 6:19 AM
Looking for a macro to quickly zap the unsightly "#/DIV/0!" message. Tried to record a macro which will:
1) Go to the formula for the active cell
2) Go to the beginning of the formula and delete the leading "=" ("home, delete")
3) Copy the rest of the formula to the clipboard ("shift/end, copy")
4) Return to the beginning of the formula ("home")and enter: "=IF(ISERROR("
5) Paste in the original formula, enter: "),""(
6) Again paste in the original formula followed by two closing parentheses.
7) Entered the result and moved down one cell
8) Thus "=B7/G8" would be converetd to "=IF(ISERROR(B7/G8),"",(B7/G8))
Of course I failed miserably. Tried to record with relative reference button selected. resulting macro doesn't work:
ActiveCell.FormulaR1C1 = "=IF(ISERROR(R[-2]C/R[-1]C),"""",(R[-2]C/R[-1]C))"
ActiveCell.Offset(1, 0).Range("A1").Select
Can someone help?
Thanks in advance.
Dwight