Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default functions & range vars

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default functions & range vars

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

--
steveB

Remove "AYN" from email to respond
wrote in message
oups.com...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default functions & range vars

Forgot to mention that it works in a macro.

May not work in a function.

--
steveB

Remove "AYN" from email to respond
wrote in message
oups.com...
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using range names in functions JDC Excel Worksheet Functions 1 May 11th 09 04:53 PM
Worksheet wide vars DoctorG Excel Programming 10 July 1st 05 04:26 PM
= How to setup vars when a workbookopen event is launched? hcova[_2_] Excel Programming 1 October 21st 04 07:20 PM
Global vars Nath Excel Programming 1 July 13th 04 04:20 PM
Using Range inputs in functions Curare[_4_] Excel Programming 2 February 26th 04 11:01 AM


All times are GMT +1. The time now is 06:21 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"