|
Sub searchVIN()
Set mysheet = Workbooks("book.xls").Sheets(1)
Set searchsheet = Workbooks("book.xls").Sheets(2)
' find last Range in sheet1
mysheet.Select
lastrange = 7
Do While Not (IsEmpty(mysheet.Cells(lastrange, 1).Value))
lastrange = lastrange + 1
Loop
'find last Range in sheet2
searchsheet.Select
lastcell = Range("a1").End(xlDown).Row
'search beginn
For i = 2 To lastcell
If mysheet.Range("D25").Value = searchsheet.Range("k" & i).Value Then
Range(Cells(i, 1), Cells(i, 9)).Select
Selection.Copy
mysheet.Select
Cells(lastrange, 1).Select
ActiveSheet.Paste
lastrange = lastrange + 1
searchsheet.Select
Application.CutCopyMode = False
End If
Next |
|