G
Guest
This code picks up what is in cell B2 and copies it to every line. I need
something like a vlookup that will check every note number in the second
sheet and if it finds it in the first sheet copie the info for that
particular note number to the appropriate line. Can this be modified to work?
There can be numerous numbers - up to 5000+, which is why I need to do it in
vb. Any help would be appreciated.
Sub copydata()
Dim rng1 as Range, rng2 as Range
Dim cell as Range
with Worbooks("Book1.xls").Worksheets(1)
set rng1 = .Range(.Cells(2,"B"),.Cells(rows.count,2).End(xlup))
End With
With Workbooks("Book2.xls").Worksheets(1)
set rng2 = .Range(.Cells(2,"B"),.Cells(rows.count,2).End(xlup))
End With
for each cell in rng1
res = application.Match(cell.Value,rng2,0)
if not iserror(res) then
rng2.offset(0,36).Resize(1,16).copy _
Destination:=cell.offset(0,36)
end if
Next
End Sub
something like a vlookup that will check every note number in the second
sheet and if it finds it in the first sheet copie the info for that
particular note number to the appropriate line. Can this be modified to work?
There can be numerous numbers - up to 5000+, which is why I need to do it in
vb. Any help would be appreciated.
Sub copydata()
Dim rng1 as Range, rng2 as Range
Dim cell as Range
with Worbooks("Book1.xls").Worksheets(1)
set rng1 = .Range(.Cells(2,"B"),.Cells(rows.count,2).End(xlup))
End With
With Workbooks("Book2.xls").Worksheets(1)
set rng2 = .Range(.Cells(2,"B"),.Cells(rows.count,2).End(xlup))
End With
for each cell in rng1
res = application.Match(cell.Value,rng2,0)
if not iserror(res) then
rng2.offset(0,36).Resize(1,16).copy _
Destination:=cell.offset(0,36)
end if
Next
End Sub