title: VBA Convert array Type
body: <p>In VBA, how do I convert An array from one type to another?, in my case i want to convert an array of type "String" to type "variant" because i have a function parameter that needs an array of that type. </p>
  
  <hr>
  
  <p>here is an example code,</p>
  
  <pre><code>Sub test_highlighfind()
  
      Dim Rng As Range: Set Rng = ThisDocument.Range.Paragraphs(6).Range
  
      Dim arr() As String: arr = Split(Rng.Text)
  
      Call highlightWordsUsingFind(arr, ThisDocument, 7)
  
  End Sub
  
  Sub highlightWordsUsingFind(ByRef arr() As Variant, ByRef doc As Document, _
                              Optional ByVal HighlightColor As Integer = 6)
  
      Dim i As Long, SearchRange As Range
  
      Set SearchRange = doc.Range
  
      With SearchRange.Find
          .Format = True
          .MatchCase = False
          .MatchWholeWord = True
          .MatchWildcards = False
          .MatchSoundsLike = False
          .MatchAllWordForms = False
          .Forward = True
          .Wrap = wdFindContinue
          .ClearFormatting
  
          For i = LBound(arr) To UBound(arr)
              .Text = arr(i)
              .Execute    'Execute// Runs the find operation. Returns True if the find operation is successful
              SearchRange.HighlightColorIndex = HighlightColor
          Next
      End With
  End Sub
  </code></pre>
  
  <hr>
  
  <p>i know i can change the parameter type to "string" <code>ByRef arr() As String</code> but i have other functions that return an array of type "variant" and i need the output to the function above </p>