i use a vlookup to find a match on a different sheet with this code:

[VBA]result = Application.VLookup(str, Sheets(3).Range("A1:B" & Cells(Rows.Count, 1).End(xlUp).Row), 2, False)
MsgBox result
[/VBA]
and that works just fine while it finds something, but in 99,99% of the times it will not find anything.
that makes the result become "error 2042" and causing it to crash.

how can i avoid the msgbox-code when result is 2042?

i have tried

[VBA]if result = "error 2042"[/VBA]
[VBA]on error goto 1:
msgbox result
1:[/VBA]
[VBA]if is not err.number = 2042[/VBA]

its probably simple, what did i do wrong?