totn Excel Functions

MS Excel: How to use the LEFT Function (WS, VBA)

This Excel tutorial explains how to use the Excel LEFT function with syntax and examples.

Description

The Microsoft Excel LEFT function allows you to extract a substring from a string, starting from the left-most character.

The LEFT function is a built-in function in Excel that is categorized as a String/Text Function. It can be used as a worksheet function (WS) and a VBA function (VBA) in Excel. As a worksheet function, the LEFT function can be entered as part of a formula in a cell of a worksheet. As a VBA function, you can use this function in macro code that is entered through the Microsoft Visual Basic Editor.

Syntax

The syntax for the LEFT function in Microsoft Excel is:

LEFT( text, [number_of_characters] )

Parameters or Arguments

text
The string that you wish to extract from.
number_of_characters
Optional. It indicates the number of characters that you wish to extract starting from the left-most character. If this parameter is omitted, only 1 character is returned.

Returns

The LEFT function returns a string/text value.

Applies To

  • Excel for Office 365, Excel 2019, Excel 2016, Excel 2013, Excel 2011 for Mac, Excel 2010, Excel 2007, Excel 2003, Excel XP, Excel 2000

Type of Function

  • Worksheet function (WS)
  • VBA function (VBA)

Example (as Worksheet Function)

Let's look at some Excel LEFT function examples and explore how to use the LEFT function as a worksheet function in Microsoft Excel:

Microsoft Excel

Based on the Excel spreadsheet above, the following LEFT examples would return:

=LEFT(A1, 5)
Result: "Alpha"

=LEFT(A2, 8)
Result: "techonth"

=LEFT("Excel", 2)
Result: "Ex"

=LEFT("Excel")
Result: "E"

=LEFT("Excel", 25)
Result: "Excel"

Example (as VBA Function)

The LEFT function can also be used in VBA code in Microsoft Excel.

Let's look at some Excel LEFT function examples and explore how to use the LEFT function in Excel VBA code:

Dim LResult As String

LResult = Left("Alphabet",3)

The variable LResult would now contain the value of "Alp".