Compare columns and copy
Solved/Closed
Related:
- Compare columns and copy
- Beyond compare - Download - File management
- Display two columns in data validation list but return only one - Guide
- Tweetdeck larger columns - Guide
- How to delete rows and columns in word - Guide
- Excel compare two sheets - Guide
1 response
venkat1926
Posts
1863
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
August 7, 2021
811
Oct 8, 2011 at 10:33 PM
Oct 8, 2011 at 10:33 PM
suppose sheets 1 is like this
hdng1 hdng2
a
s
d
f
g
sheet 2 is like this
hdng1 hdng2
a 1
d 2
g 3
now in sheet 1 B2 copy this formula
=VLOOKUP(A2,Sheet2!$A$1:$B$100,2,0)
this take care of 100 rows, of necessary change it.
copy B2 down.
where the entry in sheet 1 A is not available in sheet 2 column A you will get #N/A value.
you will get sheet 1
hdng1 hdng2
a
s
d
f
g
sheet 2 is like this
hdng1 hdng2
a 1
d 2
g 3
now in sheet 1 B2 copy this formula
=VLOOKUP(A2,Sheet2!$A$1:$B$100,2,0)
this take care of 100 rows, of necessary change it.
copy B2 down.
where the entry in sheet 1 A is not available in sheet 2 column A you will get #N/A value.
you will get sheet 1
Oct 9, 2011 at 04:23 AM
Your reply give me an idea. I renamed Sheet1 & Sheet2 with "1" & "2". In Sheet "1" i insert a button with this code:
Dim i As Integer
la = Worksheets("1").Range("A" & Rows.Count).End(xlUp).Row
lb = Worksheets("2").Range("B" & Rows.Count).End(xlUp).Row
For i = 5 To la
Ma = Application.VLookup(Sheets("1").Range("A" & i), Sheets("2"). Range("B4:B" & lb, "C4:C" & lb), 2, 0)
Worksheets("1"). Range("B" & i) = Ma
Next i
It works fine!
Thank you! All the best!