Match and Copy

K

Kazza

Hi All
The code below will match Sheets 1 and 2 and when a match occurs copy
cells from sheet 2 to 1.
I need to copy the entire row of the unmatched items over to sheet 1 at
the same time. Hope this makes sense.

TIA
Karen

Sub Match()
Dim lookupRange As Range
Dim myRange As Range
Dim cell As Range
Dim myRow As Variant

Set lookupRange = Sheets("Sheet2").Range("a:a")
With Sheets("Sheet1")
Set myRange = .Range("a2:a" & .Range("a" &
Rows.Count).End(xlUp).Row)
End With
For Each cell In myRange
myRow = Application.Match(cell.Value, lookupRange, 0)
If Not IsError(myRow) Then cell.Offset(0, 1).Resize(1, 22).Value =
_
lookupRange(myRow).Offset(0, 1).Resize(1, 22).Value

Next cell

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top