title: Pass array to ParamArray
body: <p>is it possible to pass all elements of an array to a ParamArray?</p>
  
  <p>For example I'd like to pass a ParamArray to another ParamArray:</p>
  
  <pre><code>Sub test()
      p1 "test", "banane", "birne"
  End Sub
  
  Sub p1(ParamArray keys() As Variant)
      p2 keys 'should be the same as: p2 "test", "banane", "birne"
  End Sub
  
  Sub p2(ParamArray keys() As Variant)
      Dim key As Variant
      For Each key In keys
          Debug.Print key 'Run-time error '13' Type mismatch (key is an array)
      Next key
  End Sub
  </code></pre>
  
  <p>In this case ParamArray of <code>p2</code> doesn't contain the elements of <code>keys</code>, but it gets the array-object <code>keys</code>. Thus I've got to check, if an arrays is passed:</p>
  
  <pre><code>Sub test()
      p1 "test", "banane", "birne"
      p2 "test", "banane", "birne"
  End Sub
  
  Sub p1(ParamArray keys() As Variant)
      p2 keys
  End Sub
  
  Sub p2(ParamArray params() As Variant)
      Dim keys As Variant
      If IsArray(params(0)) Then
          keys = params(0)
      Else
          keys = params
      End If
  
      Dim key As Variant
      For Each key In keys
          Debug.Print key
      Next key
  End Sub
  </code></pre>
  
  <p>But this is awkward for example compared to Java:</p>
  
  <pre><code>public class VarArgs {
  
      public static void main(String[] args) {
          p1("test", "banane", "birne");
          p2("test", "banane", "birne");
  
          String[] array = {"test", "banane", "birne"};
          p1(array);
          p2(array);
      }
  
      public static void p1(String... strings) {
          p2(strings);
      }
  
      public static void p2(String... strings) {
          for (String string : strings) {
              System.out.println(string);
          }
      }
  
  }
  </code></pre>
  
  <p>In Java I don't have to distinguish. But this is probably not possible in VBA.</p>
  
  <p>Thanks for help,<br>
  Michael</p>