ParamArray - limited by 29 arguments

psoukup

New Member
Joined
Apr 7, 2015
Messages
7
Hi guys,
I created UDF using paramArray expecting I can use as many params I want (the function will be used under Excel 2003/7/10). However once I exceed 29 params I get an error message
"More arguments have been specified for this function that are allowed in the current file format"

is there any workaround, is number of args in the ParamArray really limited?
here is my funtion (shorten)

Function dwhBAL(ParamArray Params() As Variant) As Variant


Set cnn = New ADODB.Connection
Set rst = New ADODB.Recordse
With cnn

.ConnectionString = conString
.CursorLocation = adUseClient
.Open
End With

For i = LBound(Params) To UBound(Params)

Select Case UCase(Params(i))
Case "ACCOUNT", "ACC": thisPodminka

.......

rst.Open dwhBAL, cnn, adOpenStatic, 3 'adLockReadOnly
varData = rst.GetRows()


ReDim varDataT(1 To UBound(varData, 2) + 1, 1 To UBound(varData, 1) + 1)
dwhBAL = Nz(mySum + varData(0, 0))

End function



thank you
 
Don't think so, but to Norie's point, I can't get my brain around a function that needs more than 29 discrete arguments.
 
Upvote 0

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
hardly to imagine, I agree.
My function queries MSSQL tables from the financial system. To make it flexible user can specify name for the fields he wants to use in the condition, each condition uses 3 arguments FieldName, LowLimit, TopLimit
so 30 arguments quickly shrinks to 10 real parameters and then it it is not so difficult to run out of the range
Example:
currency from to, period from To, actuality from to , account from to, CC from to, customer from to, etc.
and you can imagine users are very creative :)

anyway thank you to all of you for quick responses
rgds Pavel
 
Upvote 0
Instead of having the users hard code those strings directly into your function.
Have them put them into a range of cells.
Then reference that range in the function.
And you can loop that range using something like

Code:
Public Function x(MyRange As Range)
For Each c In MyRange
 
Last edited:
Upvote 0
Why not just get them to put that into a table with three headers, Field, LowLimit, TopLimit - they can then have as many rows as they want

Jonmo beat me to it!
 
Upvote 0
Or if they get collected hither, thither, and yon from the worksheet, at least use arrays of three items each.
 
Upvote 0

Forum statistics

Threads
1,215,561
Messages
6,125,542
Members
449,236
Latest member
Afua

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top