Summing

G

Guest

I want to set a column equal to the sum of some other
columns in a macro. It is not working. Can you help.
This is what I have.

Range("A" & m).Value = SUM("V" & m: "V" & (n-1))

Thank you
 
J

JWolf

Two options:
Range("A" & m).formula = SUM("V" & m: "V" & (n-1)) 'puts the formula
into the cell Am
Range("A" & m).Value = worksheetfunction.SUM("V" & m: "V" & (n-1))
'puts the result of the sum into cell Am
 
B

Bob Phillips

Range("A" & m).Value = WorksheetFunction.SUM(Range("V" & m & ":V" & (n-1))

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
J

JWolf

Yep, it wouldn't. Do like Bob says and move the colon inside the quote
for the second V.
 
B

Bob Phillips

JWolf said:
Two options:
Range("A" & m).formula = SUM("V" & m: "V" & (n-1)) 'puts the formula
into the cell Am

I think that you mean

Range("A" & m).formula = "=SUM(V" & m & ":V" & (n-1) & ")"
Range("A" & m).Value = worksheetfunction.SUM("V" & m: "V" & (n-1))
'puts the result of the sum into cell Am

Range("A" & m).Value = worksheetfunction.SUM("V" & m & ":V" & (n-1))
 
Top