PDA

View Full Version : I know they all are criminals(a specific datatype) But dont know how many?



prabhafriend
01-05-2010, 08:11 AM
How to pass a dynamic array of “strings” to a function as an argument?

GTO
01-05-2010, 08:22 AM
Guessing a bit here, but if you mean the number of strings you want to pass is dynamic, try ParamArray. See vba help and not that it must be the last arg and a variant.


Sub exa()
Call test("one")
Call test("One", "Two")
End Sub

Function test(ParamArray MyStrings() As Variant)
Dim i As Long

For i = LBound(MyStrings) To UBound(MyStrings)
MsgBox MyStrings(i)
Next
End Function


Hope that helps,

Mark

prabhafriend
01-05-2010, 08:25 AM
We can't specify the datatype here. Because It will create complexities in Validations. Thank you.

Paul_Hossler
01-08-2010, 07:19 AM
Worksheet function or VBA function?

Paul

SamT
01-09-2010, 08:31 AM
I think he wants to pass a dynamic array to a sub as a By Ref.
ie.

Sub SomeSub()
Dim SomeDynamicArray as String
MySub SomeDynamicArray
End Sub

Sub MySub(MyArray)
Do Something with MyArray 'SomeDynamicArray
End Sub