PDA

View Full Version : Syntax Help



keentolearn
10-21-2008, 05:35 AM
Hi,


Cells(compLDR + 1, 6) = Application.WorksheetFunction.Sum(COMPR.Range("F3:F" & compLDR))
The above code is working well. But if I want it to write it as below it is not working

Cells(compLDR + 1, 6).Formula = " =Sum(COMPR.Range("F3:F" & compLDR))"
As I am very much a starter in VBA I couldn't make it this.

Any help is appreciated.

Bob Phillips
10-21-2008, 05:40 AM
Cells(compLDR + 1, 6).Formula = " =Sum(F3:F" & compLDR & ")"


or



Cells(compLDR + 1, 6).FormulaR1C1 = "=Sum(R3C:R[-1]C)"

keentolearn
10-21-2008, 05:55 AM
Hi xld,


Cells(compLDR + 1, 6).Formula = " =Sum(F3:F" & compLDR & ")"

This code is giving the result in the required cell as

=Sum(F3:F8) instead of value.

Bob Phillips
10-21-2008, 06:11 AM
Sorry, I copied your formula with ist space. Should be



Cells(compLDR + 1, 6).FormulaR1C1 = "=Sum(R3C:R[-1]C)"

keentolearn
10-21-2008, 10:34 AM
Thank you xld.

Actually the R1C1 formula worked well for me. The problem was with the other one. But your explanation cleared me where I was doing mistake. It is the space in the formula.

Have a good day.