look up syntax

  • Thread starter Thread starter Pierre
  • Start date Start date
P

Pierre

Hi all,

I made a small form to enter data in an excel sheet

Before accepting each record, i want to validate a code number

If the code exist in a simple colum on an other sheet name lookup i will
add the data
otherwise i will beep to make a warning.

if i write

If VLookup(tmp, "lookup!a1:a980", 2) Then
MsgBox "found!"
Else
beep
End If

vba tell me vlookup does not exist ???
the sheet llok up is like
a1 b1
code1 1
code2 1
code3 1

Help

Pierre
 
Dim res as Variant
res = Application.Match(tmp,Range("Lookup!A1:A980"),0)
If not iserror(res) Then
MsgBox "found!"
Else
beep
End If
 

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