writing a formular into one cell of an excel sheet

  • Thread starter Thread starter Matthias Frohnapfel
  • Start date Start date
M

Matthias Frohnapfel

Hello,

I've a VBA Macro. This should write a formular like

=wenn(x>y;"ja";"nein")

in a cell. I tried this: Range("B9").value = "=wenn(x>y;"ja";"nein")"

I think there is also a problem with executing this formular. Can somebody
help me, please?

Thank you!
 
Hi Matthias,

The quotation marks inside you IF formula need to be doubled, i.e.

Change: "=wenn(x>y;"ja";"nein")"

to: "=wenn(x>y,""ja"",""nein"")"


Of course this IF formula will return an error unless x>y represents a
logical condition which the worksheet can evaluate.
 
Hello,

there is still an error. This is my real formula:

Range("B9").Value = "=WENN(B28>(B22+0,75*(B29-B22));""ja"";""nein"")"

I want to write the formula =WENN(B28>(B22+0,75*(B29-B22));""ja"";""nein"")
into a cell. After that, Excel should execute this formula, so that I get
"ja" or "nein".

Thank you!
 
Hi Matthias,

The English version of your formula is :

=IF(B28>(B22+0.75*(B29-B22)),"ja","nein")

Using the VBA expression:

Range("B9").Value = "=IF(B28>(B22+0.75*(B29-B22)),""ja"",""nein"")"

returns ja (or nein) in cell B9 for me.

As I have an English version of Excel, I cannot test, but I can see no
reason why, if the equuivalent German worksheet function exprssion:

=WENN(B28>(B22+0,75*(B29-B22));"ja";"nein")

works, the VBA expression:

Range("B9").Value = "=WENN(B28>(B22+0,75*(B29-B22));""ja"";""nein"")"

should return an error.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top