Vba add absolute reference formula in Excel
For example, I want to enter the formula "=Iferror(B2/C2,"")" in Cell D2 using VBA
To do it in Excel, here is the answer:
- Option Explicit
- Sub AddFormula()
- ActiveSheet.Range("D2").Formula = "=IFERROR(B2/C2,"""")"
- End Sub
a) Line 3 - The exact formula text including "=" should appear within double quotes. Notice the use of specifying quotes twice within brackets so that they appear once in formula when written to cell.