title: Using a macro to create new function LookUpConcat but it crashes
body: <p>I need to join text from cells together into one cell.  I found this macro which was written sometime ago, which may be my problem, that creates a new function in excel called <code>LookUpConcat</code>.  The first time I copied it into my VBA and create the formula <code>=LookUpConcat($B$2,Usage!$AA$2:$AA$5000,$AG$2:$AG$5000," ")</code> it seemed to worked great.  Then it start crashing and giving me a <code>#NAME</code> error, so I started fresh. Now it says it has a compile error at each of the = signs in the beginning.  (String = " ", Boolean = True,....)</p>
  
  <pre><code>Function LookUpConcat(ByVal SearchString As String, SearchRange As Range, ReturnRange As Range, _
                         Delimiter As String = " " , MatchWhole As Boolean = True, _
                         UniqueOnly As Boolean = False,  MatchCase As Boolean = False)
  
    Dim X As Long, CellVal As String, ReturnVal As String, Result As String
  
    If (SearchRange.Rows.Count &gt; 1 And SearchRange.Columns.Count &gt; 1) Or _
       (ReturnRange.Rows.Count &gt; 1 And ReturnRange.Columns.Count &gt; 1) Then
      LookUpConcat = CVErr(xlErrRef)
    Else
      If Not MatchCase Then SearchString = UCase(SearchString)
      For X = 1 To SearchRange.Count
        If MatchCase Then
          CellVal = SearchRange(X).Value
        Else
          CellVal = UCase(SearchRange(X).Value)
        End If
        ReturnVal = ReturnRange(X).Value
        If MatchWhole And CellVal = SearchString Then
          If UniqueOnly And InStr(Result &amp; Delimiter, Delimiter &amp; ReturnVal &amp; Delimiter) &gt; 0 Then     GoTo Continue
          Result = Result &amp; Delimiter &amp; ReturnVal
        ElseIf Not MatchWhole And CellVal Like "*" &amp; SearchString &amp; "*" Then
          If UniqueOnly And InStr(Result &amp; Delimiter, Delimiter &amp; ReturnVal &amp; Delimiter) &gt; 0 Then     GoTo Continue
          Result = Result &amp; Delimiter &amp; ReturnVal
        End If
  Continue:
      Next
  
      LookUpConcat = Mid(Result, Len(Delimiter) + 1)
  </code></pre>