Why can't I sum up these cells???


Posted by Brian A on April 20, 2001 2:41 PM

I'm trying to do a simple sum of cells using a variable to know how far to count back.

Here's my code . . .

.Range("F" & SMCBegin & ":" & "F" & SMCEnd + 1).select
.Range("F" & SMCEnd + 1).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-SMCCount]C:R[-1]C"

It bombs on the ActiveCell line. I know the syntax must be slightly off or something when I use the variable SMCCount.

Thanks for any help!



Posted by Dave Hawley on April 20, 2001 3:32 PM


Hi Brian

Put the formula in the cell how you want it then select the cell. Record a macro and Push F2 then enter. Stop recording and use the code and replace what you need to replace. Eg;

"=SUM(R[-" & SMCCount & "]C:R[-1]C"


I can't work out the C:R or C bit ?


Dave

OzGrid Business Applications