Consulting

Results 1 to 5 of 5

Thread: How to pass a part of a Nested Array to a function?

  1. #1

    How to pass a part of a Nested Array to a function?

    fieldnames = Array(Array("Account Class", "LE", "Acc-Pro", "BU", "DS", "CCY", "Value"), Array("Account Class", "Legal Entity", "Account", "Business Unit", "Data Source", "CCY", "Balance (USD)"), , Array("Account Type", "Legal Entity", "Account", "Product", "Business Unit", "Data Source", "Transaction Currency", "USD Equiv - Prior Period"), Array(, , "+-", "=Right((), 6)", , "=Left((),3)"))

    i=0
    Call Locate_Matrix(files(i), fieldnames(i+1))

    Function Locate_Matrix(ByVal bookname As String, fieldlist() As Variant) As Boolean

    Why I am getting an Type mismatch saying "Array or User-defined type expected" Highlighting the fieldnames(i+1). At the same time Isarray(fieldnames(i+1)) returns true. How come?

  2. #2
    I think the signature of the function is wrong, change:

    Function Locate_Matrix(ByVal bookname As String, fieldlist() As Variant) As Boolean


    to:

    Function Locate_Matrix(ByVal bookname As String, fieldlist As Variant) As Boolean
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  3. #3
    that means there is no need to explicitly declare variable as an array in functional parameters?

  4. #4
    No, it means that you can assign an array to a variable of type Variant, without declaring it as an array of variants.
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  5. #5
    Thank you Jan.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •