How to write an excel formula into a cell using VBA. [Tutorial]

Using VBA we can write formulas into an excel cell and the formula will start function immediately after the VBA code execution

Below VBA code implement a formula into selected cell:

Sub Insert_formula()

Dim frmla as string
frmla = “=SUM(R2C10:R20C10)”
ActiveCell.FormulaR1C1 = frmla

End sub


Complex formulas also can be implemented in the same manner. Ie convert the formula to a string and assign it to active cell

    Blogger Comment
    Facebook Comment
 
Copyright © 2013. New Techie - All Rights Reserved
Template Created by ThemeXpose