VBA LEFT Function (Syntax + Example)

- Written by Puneet


The VBA LEFT function is listed under the text category of VBA functions. When you use it in a VBA code, it returns a sub-string from a string from the starting position. In simple words, you can extract a number of characters from a string from its starting (which is the left side). It simply works like the LEFT function in the worksheet.


Left(Str, Length)


  • Str: The string from which you want to extract a substring.
  • Length: The integer to specify the length of the substring.


To practically understand how to use VBA LEFT function, you need to go through the below example where we have written a VBA code by using it:

Sub example_LEFT()
Range("B1").Value = Left(Range("A1"), 5)    
End Sub

In the above code, we have used LEFT to get the 5 characters from the left side of cell A1 (Excel Champs) and put them in cell B1. It has returned the value (Excel) in the result as these are the first 5 characters in cell A1.

Last Updated: July 07, 2024