functions & range vars

  • Thread starter Thread starter rcmcll
  • Start date Start date
R

rcmcll

Greetings:
I'm trying to do something that should be easy but can't find a decent
book. I'm using Excell 2000 and want to create a custom sum function
that handles more than one conditional. Can't figure out how to get
range into the function and use it in the calcs.

Mysumif(RngOne as Range)

For i = first cell to last cell in range
If .... and ... Then sum this cell into total. (like that see?)
next i

then use it like any function:

Mysumif("A1:A50")

any suggestions?

Thanks,
Bob
 
If I understand you correctly -
[ cells(rw,1) represents each cell in column A]

Dim sm as Double, rw as Long

sm = 0

For rw = 1 to lastrow
If Cells(rw,1) = [ put in your condition ] then
sm = sm + Cells(rw,1)
Elseif '<<<< use for additonal conditions, add as many as needed...

Else

End If
Next
 
Forgot to mention that it works in a macro.

May not work in a function.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top