Change to this
Code:
Dim Rng1A As Range, Rng2B As Range ' , Rng2A As Range
Set Rng1A = Rng1.Range("A1:A" & Rng1.Rows.Count & ""): Set Rng2B = Rng2.Range("B1:B" & Rng2.Rows.Count & "") ' : Set Rng2A = Rng2.Range("A1:A" & Rng2.Rows.Count & "")
Rem 2 take each row in column A of 1.xlsx and compare it with each row in column B of of 2.xlsx
Dim Rws As Long
For Rws = Rng1.Rows.Count To 2 Step -1
If Rng1A.Item(Rws).Value = Rng2B.Item(Rws).Value Then
' Do nothing
Else
Rng2B.Item(Rws).EntireRow.Delete Shift:=xlUp
End If
Next Rws
End Sub
Before:-
_____ Workbook: 1.xlsx ( Using Excel 2007 32 bit )
Row\Col |
A |
B |
C |
1 |
|
|
|
2 |
ACC |
6 |
|
3 |
DLF |
4 |
|
4 |
|
|
|
Worksheet: Sheet1
_____ Workbook: 2.xlsx ( Using Excel 2007 32 bit )
Row\Col |
A |
B |
C |
D |
E |
F |
G |
1 |
Exchange |
|
|
|
|
|
|
2 |
NSE |
ACC |
EQ |
10 |
11 |
12 |
13 |
3 |
NSE |
ADANIENT |
EQ |
8 |
7 |
6 |
5 |
4 |
NSE |
DLF |
EQ |
1 |
2 |
3 |
4 |
5 |
|
|
|
|
|
|
|
Worksheet: Sheet1
After:
_____ Workbook: 1.xlsx ( Using Excel 2007 32 bit )
Row\Col |
A |
B |
C |
1 |
|
|
|
2 |
ACC |
6 |
|
3 |
DLF |
4 |
|
4 |
|
|
|
Worksheet: Sheet1
_____ Workbook: 2.xlsx ( Using Excel 2007 32 bit )
Row\Col |
A |
B |
C |
D |
E |
F |
1 |
Exchange |
|
|
|
|
|
2 |
NSE |
ACC |
EQ |
10 |
11 |
12 |
3 |
NSE |
DLF |
EQ |
1 |
2 |
3 |
4 |
|
|
|
|
|
|
5 |
|
|
|
|
|
|
Worksheet: Sheet1
Bookmarks