Using vlookup in VB

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • samadelaide
    New Member
    • Aug 2007
    • 1

    #1

    Using vlookup in VB

    Hi,

    I'm trying to create some vlookups that will be looking to a different workbook each time.

    This is what I've got thus far:]

    Private Sub Vlookups()

    ' Find Stock in foreign worksheet and lookup data
    Dim Name As Variant
    Dim Asset As Range
    Dim Location As String
    Dim lFile As String
    Dim wb As Workbook
    Dim sFound As Long



    'Sets range
    Location = InputBox("Pleas e enter the name of the file, including directory, where the client's previous information is stored", _
    "Enter Information", "Document 1")
    ' MsgBox "The document's location is " & DocName
    lFile = wb("Location"). Worksheets("She et 1").Range("A1:Z 100")

    Set Asset = Range("B1")
    Answer = Application.Wor ksheetFunction. VLookup(Asset, lFile, 3, False)
    Answer = Range("C1").Val ue

    End Sub

    It comes up with an "Object Variable or With block variable not set" error for the lFile line.

    Any help would be much appreciated
    Cheers
    Sam
Working...