Thread: How To Sum
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default How To Sum


LastRow = Cells(Rows.Count,"B").End(xlUp).Row
Cells(LastRow,"B").Formula = "=SUM(B1:B" & LastRow & ")"

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"hon123456" wrote in message
ps.com...
Dear All,

I have an excel sheet which will be filled with data from
database dynamically, e.g.

Field_A Field_B

A 1
B 2
C 3
D 4

Now after the data has been filled, I want Excel to add a
Total sum following the last record.
just like following:

Field_A Field_B
A 1
B 2
C 3
D 4
Total 10

How can I do that in VBA?

Thanks.