vlookup in vba

  • Thread starter Thread starter Jilly
  • Start date Start date
J

Jilly

Hi
Anyone help with the proper syntax for the following. Or
suggest an appropriate method to achieve the same.
Jilly

Range("A2:A3").Select
Idate = ActiveCell
Idate = vlookup(r[1]c[1],sheet2!r[1]c[1]:r[64994]c
[1],1)
MsgBox "Not Their"
 
Dim iDate as Variant
Range("A2:A3").Select
set rng = Worksheets("Sheet2").Range("B2:B64993")
iDate = Application.Match(Range("A2"),rng,1)
if iserror(iData) then
msgbox "Not found"
else
msgbox idate
end if

if you looking for a date, change Match to

iDate = Application.Match(clng(Range("A2")),rng,1)

Change B2:b64993 to whatever range you want to search - it wasn't clear from
you notation what range you wanted. Same with activeCell. If you want to
get the search string from another cell, change Range("A2") to reflect that
cell.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top