Consulting

Results 1 to 3 of 3

Thread: Solved: VLOOKUP

  1. #1

    Solved: VLOOKUP

    Hi,

    I know how to use VLOOKUP function in EXCEL.
    I am looking to learn that how I can use it in VBA as
    [VBA]
    (1) Worksheetfunction
    or
    (2) UDF[/VBA]


    For example,
    A25:A50 contains ProductID
    B25:B50 contains ProductName

    How can I use VLOOKUP or similar function in VBA to find ProductName, if I have ProductID available?

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Dim cell As Range

    On Error Resume Next
    Set cell = Range("A25:A50").Find("productid")
    On Error GoTo 0
    If Not cell Is Nothing Then

    MsgBox cell.Offset(0, 1).Value2
    End If
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Thanks. It solved this problem.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •