Home |
Search |
Today's Posts |
#13
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Tom-
Thanks again for your help. For clarification, this is what I'm asking... I currently have the following, which of course breaks down once you hit the limit of 29 arguments: In the Worksheet: =Newton(B11,B12,B13,B14,B15,B16,B17,B18,B19,B20,B2 1,B22, B23,B24,B25,B26,B27,B28,B29,B30,B31,B32,B33,B34,B3 5,B36,B37, B38,B39,B38) In VB: Function Newton(P, n, F, A1, m1, A2, m2, A3, m3, A4,m4, A5,m5,A6, m6, A7, m7, A8, m8, A9, m9, A10,m10, A11, m11, A12, m12, A13, m13, iannual) To redesign, this, then: In the Worksheet: =Newton(B11:B39,B8) In VB: Function Newton(.......?) This is where I don't know what to do. Can you please specify the exact statements to accomplish what I need? Thanks again, Peter "Tom Ogilvy" wrote: Not sure what you are asking. If you mean how to handle multiple cell arguments Public Function NonZeroAverage(rng1 as range, rng2 as range) Dim tot as Double, cnt as Long tot = 0 cnt = 0 for each cell in rng1 if isnumeric(cell) then tot = tot + cell.Value cnt = cnt + 1 end if Next for each cell in rng2 if isnumeric(cell) then tot = tot + cell.Value cnt = cnt + 1 end if Next if cnt < 0 then NonZeroAverage = tot/cnt else NonZeroAverage = 0 end if End Function This is just for illustration. You are probably using a Paramarray, but it illustrates handling any rng argument as if it was multicell. A single cell argument would not cause a problem. -- Regards, Tom Ogilvy "Peter M" wrote in message ... Thanks Tom. But what about the statement in the function itself? Function myFuntion(?,x) "Tom Ogilvy" wrote: =myFunction(B11:B39,B8) is two arguments. You have 27 left. You have to write your function to work with multiple cells in a single argument. -- Regards, Tom Ogilvy "Peter M" wrote in message ... Nick- Thanks for your reply. Perhaps so. My programming experience is Fortran (which obviously dates me), and in Fortran it is not uncommon to have a long argument list. I would be happy to redesign if I knew how. What I am doing is passing values in cells, say B11:B39 & B8 into a function I wrote in VB which performs Newton-Raphson iteration and returns a single value, which is the result of the iteration. Up to now the number of arguments I passed was under the limit of 29. I need to be able to pass more than 29 though. How can I pass these arguments, using the example I give above, pass B11:B39 & B8. Also, what do I need to do to the function statement (if anything) to receive arguments passed in an array form. Thanks, Peter "NickHK" wrote: Peter, IMO if you are passing 30 arguments, you should look at your design again. If it really require these 30 different pieces of information to return a single answer, you may be trying to do too much in one function. If you are passing 30 cell values to calculate say an average, just pass the Range concerned. NickHK "Peter M" wrote in message ... Thanks. It's 30, because that's what I'm hitting. The error message isn't very gooog though; it just says you are trying to pass too many arguments for the function, instead of you've hit the limit. Anyway, I know about arrays, but what are user defined types? "Jim Thomlinson" wrote: Yup but I do not remember what it is. Something like 40. You can pass arrays and user defined types though if you get into trouble. "Peter M" wrote: Is there a limit on the number of arguments you can have in a user defined Function in Excel? -- Thanks for any help |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Workaround for HYPERLINK argument length limit | Excel Worksheet Functions | |||
How can I get around 30 argument limit of SUM function? | Excel Worksheet Functions | |||
Array as Argument in User-Defined Functions | Excel Programming | |||
Array as Argument in User-Defined Functions | Excel Programming | |||
Passing an Array of User-Defined Type to an Argument of a Function | Excel Programming |