jeudi 23 juillet 2015

Change range formula to include multiple if statements VBA

Bonjour!

I am trying to fill some cells with If functions. In excel this would look like this:

=if(B11="Apple"; "nice";if(B11="Banana";"Also nice";"why?")

If I only use the first part of the if statement the code runs without problem

rng.formula = "=if(B11=""Apple"", ""Nice"", ""why?"")"

However, as soon as I add another if I get an

Run Time Error '1004' Application defined or object-defined error

rng.Formula = "=if(B11=""Apple"",""Nice"",if(B11=""Banana"",""Also nice"",""why?"")"

How can I include several

Aucun commentaire:

Enregistrer un commentaire