4. VBA Tips - Finding things using VBA

Nick's picture


Don't use VLOOKUP, INDEX, or MATCH from VBA when finding things on a worksheet with VBA.

 

  • The problem with these is that when the function doesn't find something, it will return a VBA error which you then have to trap and handle successfully.
  • This is a very messy way of coding, and prone to errors.

The best way to look for things on a sheet is to use .Find

Here's an example that finds all whole instances of "Nick" on this sheet:

FIND-VBA-1 

 

This code will find all instances of "Nick":

FIND-VBA-2 

Download workbook with code on how to find all instances of a string on a worksheet

Training Video on how to use FIND in VBA: