32 Contributors: 2 Tuesday, August 9, 2016
Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Rip Tutorial:
Roadmap: roadmap



VBA has built-in functions for extracting specific parts of strings, including:

  • Left/Left$
  • Right/Right$
  • Mid/Mid$
  • Trim/Trim$

To avoid implicit type conversion onverhead (and therefore for better performance), use the $-suffixed version of the function when a string variable is passed to the function, and/or if the result of the function is assigned to a string variable.

Passing a Null parameter value to a $-suffixed function will raise a runtime error ("invalid use of null") - this is especially relevant for code involving a database.

Related Examples