![]() |
How to sum using vba
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 |
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 |
All times are GMT +1. The time now is 01:31 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com