ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Writing a formula into a cell (https://www.excelbanter.com/excel-programming/289145-writing-formula-into-cell.html)

Dr. Schwartz[_3_]

Writing a formula into a cell
 
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


Bob Phillips[_6_]

Writing a formula into a cell
 
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)

"Dr. Schwartz" wrote in message
...
How should the code look like if I want my macro to enter a formula into a

cell.

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

Any help is appriciated, thank you.
Schwartz




tolgag[_25_]

Writing a formula into a cell
 
If you don't want to use R1C1 syntax, try this :

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

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 10:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com