title: How to print the sorted array in word using VBA?
body: <p>I have a two Input data of Year and Name in separate two arrays. I need to sort both the array values first i need to sort it chronologically(Year) and then if year information repeats it will sort the Array Alphabetically.</p>
  
  <p>As for as I complete the sorting for both year and then name. Using <code>Wordbasic.sortarray</code> command</p>
  
  <p><strong>Input</strong>: (Before sorting)</p>
  
  <pre><code>SDF 1997
  ELS 1986
  PJK 1983
  WKL 1995
  EFD 1986
  </code></pre>
  
  <p><strong>Output</strong>: (After sorting)</p>
  
  <pre><code>PJK 1983
  EFD 1986
  ELS 1986
  WKL 1995
  SDF 1997
  </code></pre>
  
  <p>If I print it in word it printed like this:</p>
  
  <pre><code>PJK 1983, ELS 1986, EFD 1986, WKL 1995, SDF 1997.
  </code></pre>
  
  <p>Here is my code for Printing the data. Would anyone please look into this and guide me where did i made mistake?</p>
  
  <pre><code>WordBasic.sortarray SortyearArray()
  </code></pre>
  
  <p><strong>Code</strong>:</p>
  
  <pre><code>Dim I As Integer
  Dim J As Integer
  Dim K As Integer
  Dim N As Integer
  Dim Counter As Integer
  COUNTER1 = 1
  
  i1 = 1
  J1 = 5
  
  For I = 0 To UBound(SortyearArray())
      Counter = 1
      For J = I + 1 To UBound(SortyearArray())
          If SortyearArray(I) = SortyearArray(J) Then
              Counter = Counter + 1
              MsgBox (Counter)
          End If
          COUNTER1 = Counter + COUNTER1
      Next J
      If Counter = 1 Then
          For N = i1 To J1
              If SortyearArray(I) = Year(N) Then
                  Selection.TypeText Text:="(" &amp; AuthorName(N) &amp; Year(N) &amp; ")"
              End If
          Next N
      End If
  Next I
  </code></pre>