Writing a formula into a cell

D

Dr. Schwartz

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
 
B

Bob Phillips

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)
 
T

tolgag

If you don't want to use R1C1 syntax, try this :

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