Related:

- Compare cell a1 to entire A col in sheet2
- Excel - Comparing cell A1 to entire A column in Sheet 2 - How-To - Excel
- Delete entire content if cell A1 value change ✓ - Forum - Office Software
- Excel - Comparing cells across multiple columns - How-To - Excel
- If cell A1 has text then cell B2 has today's Date ✓ - Forum - Excel
- Compare cells of two columns excel 2007 ✓ - Forum - Excel

Ivan-hoe

- Posts
- 433
- Registration date
- Saturday February 16, 2008
- Status
- Member
- Last seen
- October 17, 2008

Hello Bill,

when you write

you copy the whole range "Data_2", which corresponds to the column A of the sheet "Inventory"

If you want to copy only the rows in Data_2 that match with Data_1, do write

I hope it helps

Ivan

when you write

Data_2.EntireRow.Copy

you copy the whole range "Data_2", which corresponds to the column A of the sheet "Inventory"

If you want to copy only the rows in Data_2 that match with Data_1, do write

C_2.EntireRow.Copy

I hope it helps

Ivan

Thanks

Vijay

thanks

Gaurav

Dim LastRow_1 As Integer

Dim LastCol_1 As Integer

Dim Data_1 As Range

Dim LastRow_2 As Integer

Dim LastCol_2 As Integer

Dim Data_2 As Range

Dim Sh_1 As Worksheet

Dim Sh_2 As Worksheet

Dim X As Long

Dim Y As Long

Dim C_1 As Range

Dim C_2 As Range

Set Sh_1 = ActiveWorkbook.Sheets("Sheet1")

Set Sh_2 = ActiveWorkbook.Sheets("Sheet2")

LastRow_1 = Sh_1.Range("A200").End(xlUp).Row

LastCol_1 = Sh_1.Range("O200").End(xlToLeft).Column

Set Data_1 = Sh_1.Range("A1").Resize(LastRow_1, LastCol_1)

LastRow_2 = Sh_2.Range("A200").End(xlUp).Row

LastCol_2 = Sh_2.Range("O200").End(xlToLeft).Column

Set Data_2 = Sh_2.Range("A1").Resize(LastRow_2, LastCol_2)

For Each C_1 In Data_1

For Each C_2 In Data_2

If C_1.Value <> C_2.Value Then

C_1.EntireRow.Copy Destination:= _

Sh_2.Range("A" & Rows.Count).End(xlUp).Offset(1, 0)

End If

Next C_2

Next C_1

End Sub