How to sum using vba
simply:
Option Explicit
Function Counter() As Long
Counter = _
WorksheetFunction.SumIf(Range("C1:C25"), "Band1", Range("D1:D25"))
End Function
You can easily expand by passing the ranges and criteria as parameters.
"Mr M Walker" wrote:
I am trying to sum data within excel using VBA.
What I what is a script theat adds data together everytime a criteria is met
for example
Everytime cells(r,1) = "Band1" then i want to add cells(r,2)
Band 1 may appear 500 time in 750 rows so I want to add all teh 500 together
I am sure this is not to difficult but I am just a novice.
Marcus
|