Excel Hack 28: Use macros to put formulas in cells

To place a formula in a cell using Excel VBA, use the following code:

 

Sub VBAFormula()

Range(“A3”).Value = “=AVERAGE(A1:A2)”

End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *