Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 11-09-2009
Member
 
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.
Reply With Quote
  #2  
Old 11-09-2009
Member
 
Join Date: Feb 2008
Posts: 1,848
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
Reply With Quote
  #3  
Old 11-09-2009
Members
 
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.
Reply With Quote
  #4  
Old 11-09-2009
Member
 
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
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


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


All times are GMT +5.5. The time now is 06:15 AM.