tags:

views:

136

answers:

3

This except of VBA code

summ = "СУММ(AQ" + Format(first) + ":AX" + Format(last - 1) + ")"
cell = "AQ" + Format(last) + ":AX" + Format(last)
r.range(cell).Formula = "=" + summ

should insert a formula, e.g. =СУММ(DW6:EI18) into DW19.

(СУММ is a Russian localized name for SUM)

What happens is that correct formula above appears at its proper place but displays a #NAME error. If I select the cell, put the cursor on the formula, and press enter, the formula doesn't change but starts working.

How to make the code above work?

A: 

Try this instead

summ = "=СУММ(AQ" + Format(first) + ":AX" + Format(last - 1) + ")"
cell = "AQ" + Format(last) + ":AX" + Format(last)
r.range(cell).Formula = summ
guitarthrower
Nope. Absolutely the same value will be passed to the Formula property in either case.
Gary McGill
I was thinking it may have had something to do with the + in the last line. Maybe VBA was converting erroneously the type instead of merely appending.
guitarthrower
+4  A: 

You need to set FormulaLocal instead of Formula because you use the Russian functionnames.

r.range(cell).FormulaLocal = "=" + summ

marg
A: 

I think it is the FormulaLocal answer from Marg (1st answer) even though OP hasn't marked it. There is nothing wrong with the formula itself.

Anonymous Type
comments belong to comments.
SilentGhost
I wasn't signed in, and besides, this isn't a comment, its an answer that correlates with another answer.
Anonymous Type
awesome, marked down by the comment nazi. cheers dude.
Anonymous Type