ok I am fairly new to VBA. programmer but in Cobal old school.
2 workbooks, both have ID in column A. Take ID from Wb1 find in Wb2 want to copy column M from Wb2 to column M in Wb1.
Wb1 has 605 records this were ID to find is, Wb2 has 7021 records this contains what i want to copy. My code works but when checking the data it was wrong.
if stepped thru with each loop thru code it adds 1 to the row it finds the reocord in and moves that.
first pass is correct, second pass it is off by 1 (pulls the info 1 row below). Third pass is off by 2 (pulls the info 2 rows below). fourth pass is off by 3 (pulls the info 3 rows below) ECT.
I just can't figure this out, several ways work just same results!! HELP
[code]
Sub Vend_move()
Dim wslr&, ws1lr&, i&, r&, f, wsRng, ws1Rng
Dim ws As Worksheet, ws1 As Worksheet, ws2 As Worksheet
Dim wb1 As Workbook, wb2 As Workbook
Set wb1 = Workbooks("Order_Pad")
Set wb2 = Workbooks("asset_history")
Set ws = wb1.Worksheets("MainOrder")
Set ws1 = wb2.Worksheets("asset_history")
'Set ws2 = Worksheets("Sales")
wslr = ws.Cells(Rows.Count, "A").End(xlUp).Row
ws1lr = ws1.Cells(Rows.Count, "A").End(xlUp).Row
wsRng = ws.Range("A2:N" & wslr).Value
ws1Rng = ws1.Range("A2:N" & ws1lr).Value
r = 2
For i = 1 To wslr - 1
Set f = ws1.Range("A:A").Find(wsRng(i, 1), ws1.Range("A1"))
If Not f Is Nothing Then
f.Cells(i, 7).Copy ws.Cells(r, "M")
r = r + 1
'GoTo z:
'Else
End If
'z:
Next i
[code/]
Bookmarks