Writing a formula into a cell

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How should the code look like if I want my macro to enter a formula into a cell.

Example
Cell A1 is empt
I run my macro
Cell A1 contains the formula: =IF(B1="";"Ok";""

Any help is appriciated, thank you
Schwart
 
Schwartz.

Try this

Range("A1").FormulaR1C1="=IF(RC[1],"""",""Ok"")"

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
If you don't want to use R1C1 syntax, try this :

Range("A1").FormulaLocal="=IF(" & Cells(1,2).Address & " ,"""",""Ok"")
 
Back
Top