How to Use the LEFT, LEFTBs Function in Excel
The LEFT and LEFTBs functions in Excel and Google Sheets are designed to extract a specified number of characters or bytes, respectively, from the beginning of a text string. These functions are immensely useful for separating specific sections from a cell’s content when working with text data.
Syntax:
The syntax for the LEFT function in Excel is:
=LEFT(text, [num_chars])
The syntax for the LEFT function in Google Sheets is:
=LEFT(text, num_chars)
The syntax for the LEFTBs function in Excel is:
=LEFTB(text, [num_bytes])
Examples of LEFT Function:
Below are some examples to demonstrate the use of the LEFT function:
Text | Formula | Result |
---|---|---|
This is a test | =LEFT(A2, 4) | This |
1234567890 | =LEFT(A3, 5) | 12345 |
In the first example, the formula =LEFT(A2, 4)
extracts the first 4 characters from the string “This is a test”, resulting in “This”.
In the second example, the formula =LEFT(A3, 5)
pulls the first 5 characters from “1234567890”, giving “12345”.
Examples of LEFTBs Function:
The LEFTBs function operates similarly to the LEFT function but deals with bytes instead of characters, which is particularly important when working with languages that utilize multibyte characters.
Text | Formula | Result |
---|---|---|
文A字BCD | =LEFTBs(A2, 3) | 文A字 |
12文34A字 | =LEFTBs(A3, 4) | 12文34A |
In the first example, using =LEFTBs(A2, 3)
extracts the first 3 bytes of “文A字BCD”, producing “文A字”.
In the second example, the formula =LEFTBs(A3, 4)
extracts the first 4 bytes from “12文34A字”, resulting in “12文34A”.
Both the LEFT and LEFTBs functions are valuable tools for text manipulation in Excel and Google Sheets, enabling precise extraction of text segments as needed.
More information: https://support.microsoft.com/en-us/office/left-leftb-functions-9203d2d2-7960-479b-84c6-1ea52b99640c