ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   what's the problem with this ? (https://www.excelbanter.com/excel-programming/380149-re-whats-problem.html)

JMB

what's the problem with this ?
 
I added "=", quotes around "*" and "," (after rng2). Also you need to use
the Address property for rng1 and rng2

Function mySP(rng1 As Range, rng2 As Range, Optional dec As Long = 2)
mySP = Evaluate("=SumProduct(Round(" & rng1.Address(, , , True) & "*" &
rng2.Address(, , , True) & "," & dec & "))")
End Function

"dribler2" wrote:

so short am i not to know the solution..never know the programming language.

anyone know how to make this UDfunction work..

Function mySP(rng1 As Range, rng2 As Range, Optional dec As Long = 2)
mySP = Application.Caller.Parent.Evaluate("SumProduct(Rou nd(" & rng1 * rng2,
dec & "))")
End Function

'syntax =mySP(A1:A100,B1:B100,1) ----SUM OF ROUNDED PRODUCT MADE OF 2 FACTOR
ONLY

happy holidays...
driller.


JMB

what's the problem with this ?
 
Apparently the "=" is not necessary. I guess most of the examples I've seen
use it, so I assumed it was needed.


"JMB" wrote:

I added "=", quotes around "*" and "," (after rng2). Also you need to use
the Address property for rng1 and rng2

Function mySP(rng1 As Range, rng2 As Range, Optional dec As Long = 2)
mySP = Evaluate("=SumProduct(Round(" & rng1.Address(, , , True) & "*" &
rng2.Address(, , , True) & "," & dec & "))")
End Function

"dribler2" wrote:

so short am i not to know the solution..never know the programming language.

anyone know how to make this UDfunction work..

Function mySP(rng1 As Range, rng2 As Range, Optional dec As Long = 2)
mySP = Application.Caller.Parent.Evaluate("SumProduct(Rou nd(" & rng1 * rng2,
dec & "))")
End Function

'syntax =mySP(A1:A100,B1:B100,1) ----SUM OF ROUNDED PRODUCT MADE OF 2 FACTOR
ONLY

happy holidays...
driller.


dribler2

what's the problem with this ?
 
JMB

Here's your UDfunction, after some close/open file and auto-debug from
excel, this work out for me
'--------------
Function mySP2(rng1 As Range, rng2 As Range, Optional dec As Long = 2)
mySP2 = Evaluate("=SumProduct(Round(" & rng1.Address(, , , True) & "*" &
rng2.Address(, , , True) & "," & dec & "))")
End Function
'-----------------
my quest is over for the function of sum of rounded products for 2 factors----
-----------------------------
i will post another thread for some more generic/productive
questions---maybe for 3 to 4 more factorial products...

i hope to receive more helpful reply from you
more power
driller


All times are GMT +1. The time now is 10:46 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com