Originally Posted by
Rowan
Hi Jet
If you are wanting to implement in the most efficient manner then Mike's
vlookup suggestion is the way to go. If you were doing this as an
exercise in VBA then there are a number of ways to do it. One is:
Sub lkup()
Dim BookA As Workbook
Dim BookB As Workbook
Dim lVal As String
Dim fRng As Range
Set BookA = Workbooks("WorkbookA.xls")
Set BookB = Workbooks("WorkbookB.xls")
lVal = BookA.Sheets("Sheet1").Range("A1").Value
With BookB.Sheets("Sheet1").Columns(1)
Set fRng = .Find(lVal)
If Not fRng Is Nothing Then
BookA.Sheets("Sheet1").Range("B1").Value = _
fRng.Offset(0, 1).Value
End If
End With
End Sub
Regards
Rowan
jet wrote:
> I just started VBA on excel97 and have this question:
>
> I place a value on Workbook A (e.g. A1 = cars) then I want to search
> the value from Workbook B(Column A), which is my reference. After the
> value is found (e.g. A10), I want to retrieve the value on the same
> workbook on column B (e.g. B10), the price for the car, then place the
> value on Workbook A (e.g. B1)...
>
> Is that possible?
>
> thanks,
> jet
>
>
Bookmarks