title: UDF: For cell values less than x in a column, return all values from first column
body: <p>For a data set like the following, I'd like to, if the value in Row 1 equals a specified value, return all ID column values in rows where the cell value in the specified column is less than 3. (No values repeat in the ID column or in Row 1 "headers".)</p>
  
  <pre><code>ID  | X | Y | Z    
  123 | 1 | 2 | 5    
  456 | 2 | 6 | 4    
  789 | 6 | 1 | 2  
  </code></pre>
  
  <p>e.g., if a column header = "X", return value of "123, 456". If Y, "123, 789". If Z, "789". I've found a variation of a <a href="https://stackoverflow.com/a/12588613/6724200" title="&#39;multicat formula&#39;">"multicat formula"</a> (in the edit to the linked answer) that comes close to addressing my needs, but I'm having trouble adapting it. </p>
  
  <pre><code>  Public Function MultiCat2( _
      ByRef rRng As Excel.Range, _
      Optional ByVal sDelim As String = "") _
           As String
   Dim rCell As Range
   For Each rCell In rRng
      If rCell.Value &lt; 3 Then
       MultiCat2 = MultiCat2 &amp; sDelim &amp; rCell.Text
       End If
   Next rCell
   MultiCat2 = Mid(MultiCat2, Len(sDelim) + 1)  
   End Function
  </code></pre>
  
  <p>If I run the function as is on X, for example, it returns a value of "1, 2." The result needs to always be from the ID column, regardless of the column being evaluated. That part should be simple, but I can't figure out how to do it without Offset, which doesn't help me, because the evaluated column will be variable. </p>
  
  <p>I have the plain English logic I need: "If value of cell in a1:d1 = X, MultiCat a1:a4 where cell value in [selected column] is &lt;3." I can find the column I'd like to perform the evaluation on using the Match function, and I have the code I think I need to concatenate results in a single cell. </p>
  
  <p>I just can't figure out how to incorporate the result of the Match into the function, or how to get the function to concatenate the ID column.</p>