View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Cornelius Cornelius is offline
external usenet poster
 
Posts: 15
Default Vlookup - error handling with VBA

hi;
i have the same problem and I guess you already explained the solution.
Unfortunately I have no idea of vba.

I went to Microsoft Visual Basic and put in this

myname = "test"
Set lookuprng = Worksheets("Sheet1").Range("A:C")
res = Application.VLookup(myname, lookuprng, 1, False)
If IsError(res) = False Then
MsgBox res
Else
MsgBox (myname & " Not Found")
End If


"myname" is how I want to name the formula right?
what elso do have to change to get it working? And what do I type in in
excel once i finished this?

=myname(?)

Corneluis
(didnot know that my name is so commen)




"Cornelius" wrote:

Thank you John!




"john" wrote:

not something I use but think you could use this approach:

myname = "test"
Set lookuprng = Worksheets("Sheet1").Range("A:C")
res = Application.VLookup(myname, lookuprng, 1, False)
If IsError(res) = False Then
MsgBox res
Else
MsgBox (myname & " Not Found")
End If
--
jb


"Cornelius" wrote:

Hi,

Im working on a spreadsheet where I use Vlookup to find a specific value. I
need a code for handling search values that does not exists in the range.
Instead of the standard error code, I want to display a MsgBox with
information that the search string was not found in the range.

Can someone help med with an If sentence?

- Cornelius