VLookup in VBA Help Needed
Hi,
VendorTable is a named range and not a VBA variable so you use it like the
following
c.Offset(0, -1) = Application.WorksheetFunction.VLookup(c,
Range("VendorTable"), 2, False)
Alternatively you can declare VendorTable as a range variable and use it
like your example but it needs to be done just prior to the VLooup.
Dim c As Range
Dim lRow As Long
Dim BOReport_lastRow
Dim VendorTable As Range
Worksheets("MarketList").Activate
lRow = ActiveSheet.UsedRange.Rows.Count
With Worksheets("AAV_Table")
BOReport_lastRow = .UsedRange.Rows.Count
Set VendorTable = .Range("B2:C" & BOReport_lastRow)
End With
For Each c In Worksheets("MarketList").Range("C2:C" & lRow).Cells
c.Offset(0, -1) = Application.WorksheetFunction.VLookup(c, VendorTable, 2,
False)
Next c
--
Regards,
OssieMac
|