PDA

View Full Version : How to enter a formula in Excel via VBA .Formula properity?



chamster
10-14-2007, 10:46 PM
I used the following code.
.Formula = "=MEDEL(B" & i & ":" & Chr(Asc("A") + dSpan) & i & ")"

And, since it works strangely, i have the following questions.


Is there any way for me to write "MEAN" instead of the swedish "MEDEL" and still have a swedish Excel work it out? (this is a minor issue)
For some reason, the text that gets into the cell is not "MEDEL" but "Medel". I have no idea why.
The formulas don't work. I get the error "#REFERENCE!". The funny parts is that when i click on them (or F2) and simply press enter, the value gets right! At that time, the "Medel" gets uppercased as well, perhaps that being the cause. (this is the major problem)
I tried using .Calculate on the cells to make them "press enter" for me. It didn't work.It seems that "SUM" gets translated automagically into "SUMMA". However, "MEAN" does not. Highly confusing...

So, i'll be delighted to hear any comments.

chamster
10-14-2007, 11:54 PM
Found the problem. It's AVERAGE, not MEAN. Stupid mistake.