Which of the following functions find a specific number of characters from the left of the field

Excel for Microsoft 365 Excel for Microsoft 365 for Mac Excel for the web Excel 2021 Excel 2021 for Mac Excel 2019 Excel 2019 for Mac Excel 2016 Excel 2016 for Mac Excel 2013 Excel 2010 Excel 2007 Excel for Mac 2011 Excel Starter 2010 More...Less

This article describes the formula syntax and usage of the LEFT and LEFTB  function in Microsoft Excel.

Description

LEFT returns the first character or characters in a text string, based on the number of characters you specify.

LEFTB returns the first character or characters in a text string, based on the number of bytes you specify.

Important: 

  • These functions may not be available in all languages.

  • LEFTB counts 2 bytes per character only when a DBCS language is set as the default language. Otherwise LEFTB behaves the same as LEFT, counting 1 byte per character.

The languages that support DBCS include Japanese, Chinese (Simplified), Chinese (Traditional), and Korean.

Syntax

LEFT(text, [num_chars])

LEFTB(text, [num_bytes])

The function syntax has the following arguments:

  • Text    Required. The text string that contains the characters you want to extract.

  • Num_chars    Optional. Specifies the number of characters you want LEFT to extract.

    • Num_chars must be greater than or equal to zero.

    • If num_chars is greater than the length of text, LEFT returns all of text.

    • If num_chars is omitted, it is assumed to be 1.

  • Num_bytes     Optional. Specifies the number of characters you want LEFTB to extract, based on bytes.

Example

Copy the example data in the following table, and paste it in cell A1 of a new Excel worksheet. For formulas to show results, select them, press F2, and then press Enter. If you need to, you can adjust the column widths to see all the data.

Data

Sale Price

Sweden

Formula

Description

Result

=LEFT(A2,4)

First four characters in the first string

Sale

=LEFT(A3)

First character in the second string

S

Need more help?

Access for Microsoft 365 Access 2021 Access 2019 Access 2016 Access 2013 Access 2010 Access 2007 More...Less

Returns a Variant (String) containing a specified number of characters from the left side of a string.

Syntax

Left( string, length )

The Left function syntax has these arguments:

Argument

Description

string

Required. String expression from which the leftmost characters are returned. If string contains Null, Null is returned.

length

Required. Variant (Long). numeric expression indicating how many characters to return. If 0, a zero-length string ("") is returned. If greater than or equal to the number of characters in string, the entire string is returned.

Remarks

To determine the number of characters in string, use the Len function.

Note:  Use the LeftB function with byte data contained in a string. Instead of specifying the number of characters to return, length specifies the number of bytes.

Query example

Expression

Results

SELECT Left(ProductID,3) AS FromLeft FROM ProductSales;

Returns '3' characters from left side of the values in the field "ProductID" from table "ProductSales" in column FromLeft.

VBA example

Note: Examples that follow demonstrate the use of this function in a Visual Basic for Applications (VBA) module. For more information about working with VBA, select Developer Reference in the drop-down list next to Search and enter one or more terms in the search box.

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".

Need more help?

Which of the following functions counts the number of records that have a value in the field?

The COUNT function counts the number of cells that contain numbers, and counts numbers within the list of arguments. Use the COUNT function to get the number of entries in a number field that is in a range or array of numbers.

Which of the following functions converts a value to uppercase left UCase IIF round?

The UCase() function converts a string to upper-case.

Which of the following functions rounds a value in access?

MS Access Round() Function The Round() function rounds a number to a specified number of decimal places.

Which of the following keyboard shortcuts opens the Expression Builder dialog box?

In the Design view of a query, you won't see the ellipses, but you can launch the Expression Builder with the Builder icon on the Design Ribbon, by pressing Ctrl+F2, or by right-clicking to open the shortcut menu in, for instance, a field or criteria cell.