0

I am using a Vlookup in a VBA function as follows:

result = Application.WorksheetFunction.VLookup(target_arg, table_arg, 2, False)

When an entry exists in the lookup table (table_arg), then all is well.

If an entry does not exist in the table, then the cell has a #Value! result. I've tried to do some error trapping, but once the Vlookup doesn't find a value, the function exits and none of my code after the above statement is executed.

I would like to trap this case so that I can do additional processing before I exit the function.

braX
  • 11,506
  • 5
  • 20
  • 33
John Faig
  • 3
  • 1
  • 2
  • Sorry about the duplication. I saw that post and didn't notice the error trapping code of "On Error Resume Next". I tried to create an error routine (On error goto), which only works in subs. – John Faig Feb 05 '20 at 22:07
  • Make sure you reset the error handling after the vlookup with `On Error Goto 0` otherwise you may hide other errors that need to be fixed not skipped. – Scott Craner Feb 05 '20 at 22:10

0 Answers0