Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default any more criteria condition for mySP UDF, if possible

Function mySP(positive As Boolean, dec As Long, ParamArray rng())
Dim sConditions As String
Dim sRanges As String
Dim i As Long

sConditions = "--(" & rng(0).Address(, , , True)
sRanges = "),ROUND(" & rng(0).Address(, , , True)
For i = LBound(rng) + 1 To UBound(rng)
sConditions = sConditions & "*" & rng(i).Address(, , , True)
sRanges = sRanges & "*" & rng(i).Address(, , , True)
Next i
mySP = Evaluate("=SumProduct(" & sConditions & sRanges & _
IIf(positive, "0", "<0") & "," & dec & "))")
End Function

call like

=mysp(FALSE,2,L1:L3,M1:M3,N1:N3)

for negatives

=mysp(TRUE,2,L1:L3,M1:M3,N1:N3)

for positives

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"dribler2" wrote in message
...
i am amazed with the huge help of the UDF below,
yet i am still lacking some very minor touch of possible calculating
conditions.
like,
I need to do something like this
=mySP(+,2, A1:A100,B1:B100,C1:K100) only to provide the sum of positive
rounded products
or
=mySP(-,2, A1:A100,B1:B100,C1:K100) only to provide the sum of negative
rounded products

this may be magic but i hope excel VBA is possible.

Below is the checked result from my previous post
'Use like =mySP(2, A1:A100,B1:B100,C1:K100)

Function mySPR(dec As Long, ParamArray rng())
Dim sRanges As String
Dim i As Long

For i = LBound(rng) To UBound(rng)
sRanges = sRanges & rng(i).Address(, , , True) & "*"
Next i
mySPR = Evaluate("=SumProduct(Round(" & _
Left(sRanges, Len(sRanges) - 1) & "," & dec & "))")
End Function

TFH "thanks for help" happy holidays
dribler2



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
Condition Formats for duplicates with additional criteria Blue Max Excel Worksheet Functions 5 March 19th 09 10:15 PM
Count Unique with criteria condition Spencer Hutton Excel Worksheet Functions 1 January 12th 09 06:35 PM
Using font elements as condition criteria StorageHawk Excel Worksheet Functions 2 May 22nd 08 11:28 PM
if statements with AND or OR condition criteria philwongnz Excel Programming 3 August 26th 05 07:12 PM
Assign ID based on condition(criteria) changeable[_11_] Excel Programming 1 November 7th 04 02:42 PM


All times are GMT +1. The time now is 08:36 PM.

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"