Tuesday, January 5, 2016

Add Formula To Cell With VBA

Insert Formula Into Cell With Macro  Code

           With macro , formulas inserting  are fast especially to multiple cells  .

"Sheets("DATA").Range("I2").AutoFill Destination:=Range("I2:I" & lastrow), Type:=xlFillDefault"

Issues to be considered :
- The extra quotes  must be used .
Example : "= IF(D12<=0,"”valid”,F2*H2)"

- The comma must be used instead of semicolon.
Example : "= IF(F2<=0, H2,F2*H2)" 
When used into page : "= IF(F2<=0; H2;F2*H2)"   


2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Hi, what if i want to protect columns "I" when the formulas is pasted. Is it possible?
    can you provide the example to download?
    Thanks

    ReplyDelete