Hi,
Need some help here, i want to search and copy data, below vb code did what i want on same workbook but i have one question here, let say the data stored in another workbook, how can i search and copy the data without open the workbook? what is the additional vb code and how to integarte with vb code below.
would appreciate your help.
Thanks
Code
Sub searchdatacopy()
Dim erow As Long
Dim ws As Worksheet
Dim lastrow As Long
Dim count As Integer
lastrow = Sheets(“item_price”).Cells(Rows.count, 1).End(xlUp).Row
count = 0
For x = 2 To lastrow
If Sheets(“item_price”).Cells(x, 1) = Sheet2.Range(“B3”) Then
Sheet2.Range(“A11”) = Sheets(“item_price”).Cells(x, 1)
Sheet2.Range(“B11”) = Sheets(“item_price”).Cells(x, 2)
Sheet2.Range(“C11”) = Sheets(“item_price”).Cells(x, 3)
count = count + 1
End If
Next x
If count = 0 Then
Set ws = Worksheets(“sheet3”)
erow = ws.Cells(Rows.count, 1).End(xlUp).Offset(1, 0).Row
ws.Cells(erow, 1) = Date
ws.Cells(erow, 2) = Sheet2.Range(“B3”)
Sheet2.Range(“A11:C11”).ClearContents
End If
End Sub
Display More