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 Pls advice if there is a bug in my vbe ?

You really need to stick to one thread, you have started at least 6 on this
same topic in the past few days, and now you have moved on to posting the
same problem to many newsgroups.

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"dribler2" wrote in message
...
Hello,

Is there any genius out there who can decipher this code which is
accepted/evaluated by my VB, yet do not function as it is in my
worksheet.
this is written first in my personal.xls file (on a module) and the file
was
save-as "personal.xla" file located in the XLSTART. Add-in checked in the
toolbars add-in menus.


here is the code...
'---------
Function mySPS(test, 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
If test = "POS" Then
mySPS = Evaluate("=SumProduct(" & sConditions & "0)," & sRanges & "," &
dec
& "))")
ElseIf test = "NEG" Then
mySPS = Evaluate("=SumProduct(" & sConditions & "<0)," & sRanges & "," &
dec
& "))")
ElseIf test = "ALL" Then
mySPS = Evaluate("=SumProduct(" & sRanges & "," & dec & "))")
End If
End Function

'Call expected like (must be good for max# of array factors)
'=mySPS("POS",2,L1:L3,M1:M3,N1:N3,,,,)
'for sum of negative products
'=mySPS("NEG",2,L1:L3,M1:M3,N1:N3,,,,)
'for sum of positive products
'=mySPS("ALL",2,L1:L3,M1:M3,N1:N3,,,,)
'for sum of both
--------
The following are multi-tested in my excel 2003 workbook since yesterday.
1. for =mySPS("POS",2,A1:A3,B1:B3,C1:C3) <<<<this do not works if ARRAY
factor is more than two(2): result is #VALUE!
2. for =mySPS("NEG",2,A1:A3,B1:B3,C1:C3) <<<<this do not works if ARRAY
factor is more than two(2): result is #VALUE!
3. for =mySPS("ALL",2,A1:A3,B1:B3,C1:C3,D1:D3,E1:E3,F1:F3 ,G1:G3)<<<<this
do
not works if factor is more than six(6): result is #VALUE!

------
please advice if there is a BUG in my VBe since the 3 formulas had been
tested on different array address and the workable number of arrayed
factors
goes wild and weirdoo - sometimes more or sometimes less..

your professional advice is requested...I am short in checking vb codes.

happy holidays
dribler2



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default Pls advice if there is a bug in my vbe ?

Firing off new threads at the drop of a hat is unlikely to get better or
more responses, it will probably have the opposite effect.

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"dribler2" wrote in message
...
Sorry for that, I just really need help with myExcel!

I hope you will understanding mine problem..

"Bob Phillips" wrote:

You really need to stick to one thread, you have started at least 6 on
this
same topic in the past few days, and now you have moved on to posting the
same problem to many newsgroups.

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"dribler2" wrote in message
...
Hello,

Is there any genius out there who can decipher this code which is
accepted/evaluated by my VB, yet do not function as it is in my
worksheet.
this is written first in my personal.xls file (on a module) and the
file
was
save-as "personal.xla" file located in the XLSTART. Add-in checked in
the
toolbars add-in menus.


here is the code...
'---------
Function mySPS(test, 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
If test = "POS" Then
mySPS = Evaluate("=SumProduct(" & sConditions & "0)," & sRanges & ","
&
dec
& "))")
ElseIf test = "NEG" Then
mySPS = Evaluate("=SumProduct(" & sConditions & "<0)," & sRanges & ","
&
dec
& "))")
ElseIf test = "ALL" Then
mySPS = Evaluate("=SumProduct(" & sRanges & "," & dec & "))")
End If
End Function

'Call expected like (must be good for max# of array factors)
'=mySPS("POS",2,L1:L3,M1:M3,N1:N3,,,,)
'for sum of negative products
'=mySPS("NEG",2,L1:L3,M1:M3,N1:N3,,,,)
'for sum of positive products
'=mySPS("ALL",2,L1:L3,M1:M3,N1:N3,,,,)
'for sum of both
--------
The following are multi-tested in my excel 2003 workbook since
yesterday.
1. for =mySPS("POS",2,A1:A3,B1:B3,C1:C3) <<<<this do not works if ARRAY
factor is more than two(2): result is #VALUE!
2. for =mySPS("NEG",2,A1:A3,B1:B3,C1:C3) <<<<this do not works if ARRAY
factor is more than two(2): result is #VALUE!
3. for
=mySPS("ALL",2,A1:A3,B1:B3,C1:C3,D1:D3,E1:E3,F1:F3 ,G1:G3)<<<<this
do
not works if factor is more than six(6): result is #VALUE!

------
please advice if there is a BUG in my VBe since the 3 formulas had been
tested on different array address and the workable number of arrayed
factors
goes wild and weirdoo - sometimes more or sometimes less..

your professional advice is requested...I am short in checking vb
codes.

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
any advice pls.. DumbLittleMan Excel Discussion (Misc queries) 1 September 4th 07 09:10 PM
Advice Please? Greg[_27_] Excel Programming 3 May 9th 06 10:51 AM
Help, need advice Mikeyhend[_2_] Excel Programming 3 April 16th 06 03:19 PM
need advice Sergo Excel Programming 1 February 5th 06 12:52 AM
please advice Waleed Hanafy Excel Programming 1 April 15th 04 02:50 PM


All times are GMT +1. The time now is 05:18 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"