I've annotated the macro from before as I did not explain how it works:
Code:
--------------------
Sub test()
Dim intLastrowList1, intLastrowList2
'Determine last row of data in column A in "List 1"
intLastrowList1 = Sheets("List1").Cells(65536, 1).End(xlUp).Row
'Determine last row of data in column A in "List 2"
intLastrowList2 = Sheets("List2").Cells(65536, 1).End(xlUp).Row
'Select the "List1" worksheet
Sheets("List1").Select
'Loop through row 1 to the last row of data in the "List1" worksheet
For ra = 1 To intLastrowList1
'Loop through row 1 to the last row of data in the "List2" worksheet
For rb = 1 To intLastrowList2
'Check if the current row value in column A of "List1" equals
'the current row value in column A of "List2"
'If so copy the contents of column B in "List2" to the
'current row value in column C of "List1"
If Sheets("List1").Cells(ra, 1) = Sheets("List2").Cells(rb, 1) Then Sheets("List1").Cells(ra, 3) = Sheets("List2").Cells(rb, 2)
'Move on the the next row in "List2" to check for a match
Next rb
'Move on the the next row in "List1" once all rows have been checked in "List2"
Next ra
End Sub
--------------------
Hope this helps,
B
a94andwi Wrote:
Thank you for your help. Maybe I explained it a bit clumpsy.
The scenario I am searching for is this.
Sub test()
For each part in "list1".....
Loop through part numbers in "List2".
If the loop finds the same part number as in
"List1" then....
Copy the value in column B to "List1" column
C.
End IF
Next part
End sub
Can someone give me the correct syntax for this function?
/Anders
--
ben77
------------------------------------------------------------------------
ben77's Profile:
http://www.excelforum.com/member.php...o&userid=35602
View this thread:
http://www.excelforum.com/showthread...hreadid=556905