how to use a VLOOKUP function in a VBA code?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
am a novice in excel...i have a excel sheet with 2 columns with around 10000
records.i have placed a button in the excel sheet and on clicking the button
it should find all the values in the first column which doesnt have a match
in the second column.for that i can use VLOOKUP function.but i dont know how
to use that one.
Can any one help me?

Thanks in advance....

With Regds

Sunil.T
 
Hi,

i tried ..but am getting some errors...it will be very helpful for me if
u send me the syntax regarding my req.Thanks in advance

With regds
Sunil.T
 
Hi Sunil,

Here's an example:

Private Sub CommandButton1_Click()

Set myRng = Worksheets("Sheet1").Range("A1:B10")
myLookup = 4

myValue = WorksheetFunction.VLookup(myLookup, myRng, 2)

End Sub


The table is A1:B10.
myLookup is the lookup_value which would be in column A. myValue is the
value corresponding to the myLookup as returned by the above formula.
2 is the column index number which tells the lookup to look for the
result in the second column of the table A1:B10 i.e. column B


Mangesh
 
Back
Top