0

I have written some code that builds up a matrix of values (strings and numbers). The matrix is always 3 rows and unknown columns and is sized like this:

ReDim MyMatrix(1 To 3, 1 To SelectedPivot.RowFields.Count)

I then populate the matrix with three loops.

I have written a UDF that requires 1st and 3rd row of the matrix, as follows:

Public Function MyUDF(SourceTable As ListObject, Arr1() As Variant, Arr3() As Variant)
...
End Function

...where Arr1() is the first row of 'MyMatrix' and Arr3() is third row of 'MyMatrix'

Back in the main sub, I am trying to use the UDF like this:

Result = MyUDF(SourceTable, MyMatrix(1), MyMatrix(3))

And I get the error 'Type mismatch: array or user-defined type expected'

Any suggestions on how to get this working? I thought 'MyMatrix(n)' in a two-dimensional array gives the nth row

BigBen
  • 38,994
  • 6
  • 24
  • 37
JakeyG
  • 122
  • 9

0 Answers0