title: Excel VBA import multiple matches into different columns same row
body: <p>I'm trying to import cells from another wb. So if cell in wb1 col H matches cell in wb2 col K then wb1 col k and L = wb2 col C and E in match row. Now there may be several matches so I want it to offset to the next column. m and n for next set, o and p for next, and so on.</p>
  
  <p>This is what I have so far:</p>
  
  <pre><code>Private Sub CommandButton1_Click()
  
  Dim rcell As Range, sValue As String
  Dim lcol As Long, cRow As Long
  Dim dRange As Range, sCell As Range
  Dim LastRow As Integer
  Dim CurrentRow As Integer
  
  
  Set ws1 = ThisWorkbook
  Set ws2 = Workbooks("Workbook2").Worksheets("Sheet1")
  Sheet1LastRow = ThisWorkbook.Sheets("Data").Range("H2:H50000").Value 'Search criteria column
  Sheet2LastRow = Workbooks("Workbook2").Worksheets("Sheet1").Range("Q" &amp; Rows.Count).End(xlUp).Row 'Where to look for matches
  
   With Workbooks("Workbook2").Worksheets("Sheet1")
       For j = 1 To Sheet1LastRow
           For i = 1 To Sheet2LastRow        
               If ThisWorkbook.Sheets("Data").Range("H").Value =  ws2.Cells(i, 11).Value Then
                   ws2.Cells(i, 11).Value = ThisWorkbook.Sheets("Data").Range("C").Value
                   ws2.Cells(i, 12).Value = ThisWorkbook.Sheets("Data").Range("E").Value
               End If
               If InStr(1, ws2.Cells.Value, ws1.Cells.Value) And     Trim(ws1.Cells.Value) &lt;&gt; "" Then
                   rcell.Offset(0, lcol).Value = ws2.Cells.Offset(0, 2).Value
                   lcol = lcol + 1
               End If
           Next i
       Next j
   End With
  
  End Sub
  </code></pre>
  
  <p>This doesn't work. I basically gave up since I don't know what I'm missing. </p>
  
  <p>I looked for something like this but only found something a <code>Vlookup</code> or <code>Match</code> could do.</p>