Hi,
If the array contains both strings and longs, then it must be of type Variant.
When you pass arrays in VBA, they must be passed ByRef.
Does this code clarify things for you?
Sub MyTest()
Dim varrExample(0 To 2, 0 To 1) As Variant
Dim blnResult As Boolean
'let's put some data in our array for this example
varrExample(0, 0) = "hello"
varrExample(1, 0) = "the"
varrExample(2, 0) = "world"
varrExample(0, 1) = 1
varrExample(1, 1) = 2
varrExample(2, 1) = 3
'let's pass this into our test function
blnResult = MyFunction(varrExample)
End Sub
Function MyFunction(ByRef GiveMeAnArray() As Variant) As Boolean
'do some stuff with the array
'pass a result back, in this case a boolean
MyFunction = True
End Function
I have Option Explicit enabled, so would need to to define the data types.
This is a very good habit - one which I strongly recommend.
Bookmarks