title: Error - "Expected End Function"
body: <p>I already have research and find some questions and answers similar, but I don't understand and still can't fix my problem. I have the next code:</p>
  
  <pre><code>Sub Keep_Highest_BC() 
  
      Debug.Print Time
      Application.ScreenUpdating = False
  
      Dim d As Long, dHIGHs As Object, dDUPEs As Object
      Dim v As Long, vTMPs() As Variant, iCOLs As Long, Tam As Long
  
      'On Error GoTo bm_Safe_Exit
      Set dHIGHs = CreateObject("Scripting.Dictionary")
      Set dDUPEs = CreateObject("Scripting.Dictionary")
  
      With Worksheets("Sheet1")
          iCOLs = .Columns(15).Column
          With .Cells(2, 1).Resize(.Cells(Rows.Count, 2).End(xlUp).Row - 1, iCOLs) 
              vTMPs = .Value2
          End With
      End With
  
      For v = LBound(vTMPs, 1) To UBound(vTMPs, 1)
          If vTMPs(v, 11) = "In exploration" Then
              dHIGHs.Add Key:=vTMPs(v, 5), Item:=joinAtoAQ(vTMPs, v) 
          Else
              dDUPEs.Add Key:=vTMPs(v, 5) &amp; v, Item:=joinAtoAQ(vTMPs, v)                                      
          End If
      Next v
  
      With Worksheets("Sheet1") 
          With .Cells(2, 1).Resize(.Cells(Rows.Count, 2).End(xlUp).Row - 1, iCOLs)
              .ClearContents
              With .Resize(dHIGHs.Count, iCOLs)
                  .Value = transposeSplitLargeItemArray(dHIGHs.items)
              End With
          End With
      End With
  
  bm_Safe_Exit:
      dHIGHs.RemoveAll: Set dHIGHs = Nothing
      dDUPEs.RemoveAll: Set dDUPEs = Nothing
  
  Application.ScreenUpdating = False
  
      Debug.Print Time
  End Sub
  
  Function joinAtoAQ(vTMP As Variant, ndx As Long)
      Dim sTMP As String, v As Long
  
      For v = LBound(vTMP, 2) To UBound(vTMP, 2)
          sTMP = sTMP &amp; vTMP(ndx, v) &amp; ChrW(8203)
      Next v
      joinAtoAQ = Left$(sTMP, Len(sTMP) - 1)
  End Function
  
  Function transposeSplitLargeItemArray(vITMs As Variant) 'Error is in this function
  
      Dim v As Long, w As Long, vTMPs As Variant, vITM As Variant
  
      ReDim vTMPs(LBound(vITMs) To UBound(vITMs), LBound(vITMs) To UBound(Split(vITMs(LBound(vITMs)), ChrW(8203))))
      For v = LBound(vITMs) To UBound(vITMs)
          vITM = Split(vITMs(v), ChrW(8203))
          For w = LBound(vITM) To UBound(vITM)
              vTMPs(v, w) = vITM(w)
          Next w                                ' Error point in this line
      Next v
  
  End Function
  </code></pre>
  
  <p>And when it came to the "function transposeSplitLargeItemArray" it said "Expected end function".  </p>
  
  <p>How could I resolve this and why the error?</p>