Results 1 to 10 of 49

Thread: LookUp Value and Concatenate All Found Results

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Forum Guru Rick Rothstein's Avatar
    Join Date
    Feb 2012
    Posts
    659
    Rep Power
    13
    Quote Originally Posted by theladysaphir View Post
    You are correct in your interpretation of what I am doing, and in any other case I would prefer your suggested output, but in this particular case I need the output in every cell.
    Okay, here's the solution. Rather than create a new procedure, I simply wrote a macro that repeatedly calls my LookUpConcat function (while it can be used as a UDF, it is also a perfectly good VB function as well). So, put the LookUpConcat function in a module and then put this macro in the same module...
    Code:
    Sub LookUpAndConcatenate()
      Dim Cell As Range, LastRow As Long, ResultRow As Long
      Dim SearchRange As Range, ReturnRange As Range
      Const SearchCol As String = "B"
      Const ReturnCol As String = "AU"
      Const ResultCol As String = "D"
      Const StartRow As Long = 3
      LastRow = Cells(Rows.Count, SearchCol).End(xlUp).Row
      Set SearchRange = Cells(StartRow, SearchCol).Resize(LastRow - StartRow + 1)
      Set ReturnRange = Cells(StartRow, ReturnCol).Resize(LastRow - StartRow + 1)
      For Each Cell In SearchRange
        Cells(Cell.Row, ResultCol).Value = LookUpConcat(Cell.Value, SearchRange, ReturnRange)
      Next
    End Sub
    Then, when you want to fill the cells, just run the above LookUpAndConcatenate macro. Note that I used Const statements (they declare constants) to set the various parameters from your worksheet so that you can change them later on in case things change on your worksheet for some reason.

  2. #2
    Forum Guru Rick Rothstein's Avatar
    Join Date
    Feb 2012
    Posts
    659
    Rep Power
    13
    Quote Originally Posted by theladysaphir View Post
    Thank you, this works brilliantly - being able to adjust the three column names turned out very useful in the end as I needed to change the output destination.

    The macro takes a bit longer to run than just using the UDF on the column repeatedly, but the result is far easier to work with and the spreadsheet is more stable.
    You are quite welcome... I am glad everything ended up working out for you.

Similar Threads

  1. Replies: 5
    Last Post: 06-04-2013, 01:04 PM
  2. Replies: 6
    Last Post: 12-12-2012, 08:03 PM
  3. Lookup lookup lookup just can't make it work
    By work2live in forum Excel Help
    Replies: 1
    Last Post: 12-08-2012, 11:48 PM
  4. Excel found unreadable content
    By zyousafi in forum Excel Help
    Replies: 2
    Last Post: 08-08-2012, 10:41 AM
  5. Concatenate Multiple Lookup Values in Single Cell
    By Admin in forum Download Center
    Replies: 4
    Last Post: 04-06-2012, 09:07 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •