View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Newbie : How to sum cells via VBA code.

Rich,

More flexible

lcRange = "B3:B" & Cells(Rows.Count,"B").End(xlUp).Row
ActiveCell.Formula= "=sum(" & lcRange & ")"

--

HTH

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

"Rich" wrote in message
om...
I am using Excel 97.

I want to sum the values of several cells. I tried to follow the
examples that I see in this forum and they don't work. My code looks
like :

lcRange is equal to B3:B35

ActiveCell.Value = "=sum(" & lcRange & ")"

I thought that the above command would sum up the values in a column
like an auto sum. But it does not work. Can anyone help me ? How can I
sum ???

Rich