Copy data from one excel to another

T

Terrence Brown

I need to compare one row in one excel (Wx) with another excel (Wy) and if they are same, i need to copy the adjacent cell info from Wy to Wx correspondingly.

Say Wx is the first sheet and the column is BO and Wy is the second excel and the column is E and these two columns are to be compared and for the same values the corresponding info from the column C of Wy has to be copied in to the column BX of Wx

EggHeadCafe - Software Developer Portal of Choice
Fast KeyWord String searching Algorithms
http://www.eggheadcafe.com/tutorial...3-4decf97d75ce/fast-keyword-string-searc.aspx
 
P

Per Jessen

Hi

Try this:

Sub CompareCopy()
Dim shA As Worksheet
Dim shB As Worksheet
Set shA = Worksheets("Wx")
Set shB = Worksheets("Wy")

FirstRow = 2 'Headings in row 1
LastRow = shA.Range("BO" & Rows.Count).End(xlUp).Row

For Each cell In shA.Range("BO" & FirstRow & ":BO" & LastRow)
Set f = shB.Columns("E").Find _
(what:=cell.Value, Lookat:=xlWhole, LookIn:=xlValues)
If Not f Is Nothing Then
f.Offset(0, -1).Copy cell.Offset(0, 8)
Set f = Nothing
End If
Next
End Sub


Regards,
Per

"Terrence Brown" skrev i meddelelsen
news:[email protected]...
 

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