Results 1 to 4 of 4

Thread: Use VLookup in vba

  1. #1
    Join Date
    Jan 2009
    Posts
    58

    Use VLookup in vba

    I am using i am using Visual basic and don't have much more information about VBA, in my form in need to use VLookup in VBA to find something in a list based on input in a form? I have try a lot to find over internet but was not able to get any code for it. Does anyone has any idea about the same, please reply to this thread.

  2. #2
    Join Date
    Feb 2008
    Posts
    1,852

    how to use VLookup in vba

    If you want to have Vlookup in VBA then try to use the below code, hope it works for you.

    Code:
    Private Sub txtItem1_AfterUpdate()
    
    Dim Item1 As Integer
    Dim FileName1 As String
    Dim MyRange1 As String
    
    FileName = "e:\downloaded costs\itemlist.xls"
    MyRange = "b1:b9999"
    
    Item = txtItem1.Value
    Set Rng = Worksheets(FileName1).Range(MyRange).Find(Item)
    
    If Item <> "" Then
    txtItem2.Visible = True
    Else
    txtItem2.Visible = False
    End If
    
    End Sub

  3. #3
    Join Date
    Jan 2009
    Posts
    41

    Use VLookup in vba

    I am also facing some issue with VBA. Can anyone provide me some code following are my situation

    Worksheet "sheet1" with a 3-column range called "lst_Supplier" (suppliername + telephone + fax) , worksheet "sheet2" ,cell a1 with the requested supplier_name

    Thanks in Advance.

  4. #4
    Join Date
    Dec 2007
    Posts
    93

    Use VLookup in vba

    Try to use the following code i am sure this should work for you according to your situation.

    Code:
    Sub SampleVlookUp()
    Dim rng_Requested As Range
    Set rng_Requested = Sheets("Sheet2").Range("A1")
    With Application.WorksheetFunction
    Debug.Print .VLookup(rng_Requested.Value, Range("lst_Supplier"), 2, False) 'TELEPHONE
    Debug.Print .VLookup(rng_Requested.Value, Range("lst_Supplier"), 3, False) 'FAX
    End With
    End Sub

Similar Threads

  1. How to get yes or no in Vlookup in Excel
    By Gurmeet in forum MS Office Support
    Replies: 2
    Last Post: 24-01-2012, 04:57 PM
  2. How to use VLOOKUP IF in cell that contains Text
    By RYAN$ in forum MS Office Support
    Replies: 2
    Last Post: 11-01-2012, 04:06 PM
  3. duplicate vlookup help
    By saif49 in forum Windows Software
    Replies: 1
    Last Post: 12-11-2010, 04:57 PM
  4. Using vlookup function Please help
    By CheckMeNot in forum Windows Software
    Replies: 3
    Last Post: 25-06-2009, 09:28 AM
  5. Need help for vlookup function
    By Sunny55 in forum Windows Software
    Replies: 4
    Last Post: 09-05-2009, 12:39 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,485,064.68353 seconds with 17 queries