View Single Post
 
Old 04-09-2014, 04:42 PM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim xlWkSht As Worksheet, ArrData As String, StrMatch
Dim LRow As Long, i As Long, j As Long, k As Long
With ThisWorkbook
  Set xlWkSht = .Worksheets("Sheet3")
  k = xlWkSht.UsedRange.Cells.SpecialCells(xlCellTypeLastCell).Row
  If k = 1 Then
    With .Worksheets("Sheet2").UsedRange
      xlWkSht.Cells(k, 1) = .Cells(1, 1)
      xlWkSht.Cells(k, 2) = .Cells(1, 2)
      xlWkSht.Cells(k, 3) = .Cells(1, 3)
    End With
  End If
  With .Worksheets("Sheet1").UsedRange
    LRow = .Cells.SpecialCells(xlCellTypeLastCell).Row
    For i = 1 To LRow
      ArrData = ArrData & .Cells(i, 1).Text & "|"
    Next
  End With
  With .Worksheets("Sheet2").UsedRange
    LRow = .Cells.SpecialCells(xlCellTypeLastCell).Row
    For i = 0 To UBound(Split(ArrData, "|"))
      StrMatch = Split(ArrData, "|")(i)
      For j = 1 To LRow
        If .Cells(j, 2).Text = StrMatch Then
          k = k + 1
          xlWkSht.Cells(k, 1) = .Cells(j, 1)
          xlWkSht.Cells(k, 2) = .Cells(j, 2)
          xlWkSht.Cells(k, 3) = .Cells(j, 3)
        End If
      Next
    Next
  End With
End With
Set xlWkSht = Nothing
Application.ScreenUpdating = True
End Sub
Change my "Sheet1", "Sheet2" & "Sheet3" references to whatever you actually use - I assume it's not really "A", "B" & "C".
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote