Help with Vlookup a date

  • Thread starter Thread starter Jim
  • Start date Start date
J

Jim

Please help
I am trying to use the WorksheetFunction.Vlookup to find a date on a
worksheet and then display a Msgbox containing the text in the adjacent
cell.
The date is intially entered in a textbox on a userform.
The Date Column (D) is formatted as date (dd/mm/yyyy)
However I get error 1004.


The code is as follows
MsgBox Application.WorksheetFunction.VLookup(Cdate(Textbox2),
Worksheets(2).Range("D:E"), 2, False)


Regards & TIA
 
that would mean it didn't find the value you are looking for.

Try it like this:

res = Application.VLookup(clng(Cdate(Textbox2)), _
Worksheets(2).Range("D:E"), 2, False)
if not iserror(res) then
msgbox res
else
msgbox "No match found for " & _
format(cdate(textbox2),"mm/dd/yyyy")
end if
 
Wonderful - as always "You are the man"

Tom Ogilvy said:
that would mean it didn't find the value you are looking for.

Try it like this:

res = Application.VLookup(clng(Cdate(Textbox2)), _
Worksheets(2).Range("D:E"), 2, False)
if not iserror(res) then
msgbox res
else
msgbox "No match found for " & _
format(cdate(textbox2),"mm/dd/yyyy")
end if
 
Back
Top