Visual Basic for Applications Reference

Left Function Example

This example uses the Left function to return a specified number of characters from the left side of a string.

  Dim AnyString, MyStr
AnyString = "Hello World"   ' Define string.
MyStr = Left(AnyString, 1)   ' Returns "H".
MyStr = Left(AnyString, 7)   ' Returns "Hello W".
MyStr = Left(AnyString, 20)   ' Returns "Hello World".