What is VBA LEFT Function
how to use it
To use VBA's LEFT function you need to understand its syntax and arguments:
- Str: The string from which you want to extract a substring.
- Length: The integer to specify the length of the substring.
Example to use LEFT Function in VBA
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 the cell A1 (Excel Champs) and get it in the cell B1. It has returned the value (Excel) in the result as these are the first 5 characters we have in the cell A1.
About the Author
Puneet is using Excel since his college days. He helped thousands of people to understand the power of the spreadsheets and learn Microsoft Excel. You can ﬁnd him online, tweeting about Excel, on a running track, or sometimes hiking up a mountain.