You could try with this macro (you can put B values in any order and the match is not case sensitive):
Sub Macro1()
Dim sh1 As Worksheet
Dim sh2 As Worksheet
Dim lastRow As Long, r As Long, myTest As String
Dim myNum As String, sh2Row As Long
Set sh1 = ThisWorkbook.Sheets("sheet1")
Set sh2 = ThisWorkbook.Sheets("sheet2")
sh2.Cells.ClearContents
lastRow = sh1.Cells(Rows.Count, "a").End(xlUp).Row
sh2Row = 1
For r = 1 To lastRow
If sh1.Cells(r, 1) <> myNum Then
myTest = "Mouse,Cat,Dog"
myNum = sh1.Cells(r, 1)
End If
myTest = Replace(LCase(myTest), LCase(sh1.Cells(r, 2)), "")
If myTest = ",," Then
sh1.Range(r - 2 & ":" & r).Copy sh2.Cells(sh2Row, 1)
sh2Row = sh2Row + 3
End If
Next r
End Sub
Regards,
Antonio
Bookmarks