title: Trying to convert a variant array to delimited string and always getting type mismatch
body: <p>Ultimately I'm trying to write out a range into a text file. When I get the value of the range it returns a 2d variant array. However if I try to pass it to the converting function it gives me a type mismatch error.</p>
  
  <p>The code is:</p>
  
  <pre><code>Dim Data As String
  Set ts = fso.CreateTextFile("testfile.txt", True)
  Data = ArrayToDelimitedString(wksMyWorkSheet.Range("rngMyRange").Value)
  ts.Write (Data)
  ts.Close
  
  Public Function ArrayToDelimitedString(variantArray() As Variant) As String
     Dim delimitedString As String, index As Integer
  
     For index = 1 To UBound(variantArray(1))
        delimitedString = delimitedString &amp; CStr(variantArray(1, index)) &amp; ","
     Next
     ArrayToDelimitedString = Left(delimitedString, Len(delimitedString) - 1)
  End Function
  </code></pre>
  
  <p>I'm wondering why the .Value returns a 2d array and why is it giving me this mismatch error.</p>