Функции left right excel

Excel is mostly about numerical, however, we often have data of text data type. Here are a few functions we should know to handle text data.

  • LEFT
  • RIGHT
  • MID
  • LEN
  • FIND

The LEFT function

The LEFT function returns a given text from the left of our text string based on the number of characters specified.

Syntax:

LEFT(text, [num_chars])

Parameters:

  • Text: The text we want to extract from.  
  • Num_chars (Optional): The number of characters you want to extract. Default num_chars is 1 and the number must be a positive number that is greater than zero.  

Example:

Step 1: Format your data.

Now if you want to get the first “Geeks” from “Geeksforgeeks” in B2. Let us follow the next step.

Step 2: We will enter =LEFT(B2,5) in the B3 cell. Here we want Excel to extract the first 5 characters from the left side of our text in B2.

This will return “Geeks”.

The RIGHT Function

The RIGHT function returns a given text from the left of our text string based on the number of characters specified.

Syntax:

RIGHT(text, [num_chars])

Parameters:

  • Text: The text we want to extract from.  
  • Num_chars (Optional): The number of characters you want to extract. Default num_chars is 1 and the number must be a positive number that is greater than zero.  

Example:

Step 1: Format your data.

Now if you want to get the last geeks from “Geeksforgeeks” in B2. Let us follow the next step.

Step 2: We will enter =RIGHT(B2,5) in the B3 cell. Here we want Excel to extract the last 5 characters from the right side of our text in B2.

This will return “geeks”.

The MID function

The MID function returns the text from any middle part of our text string based on the starting position and number of characters specified.

Syntax:

MID(text, start_num, num_chars)

Parameters:

  • Text: The text we want to extract from.  
  • start_num: The starting number of the first character from the text we want to extract.
  • Num_chars: The number of characters you want to extract.

Example:

Step 1: Format your data.

Now if you want to get the character “for” which is located in the middle of our text “Geeksforgeeks” in B2. Let us follow the next step.

Step 2: We will enter =MID(B2,5,3) in the B3 cell. Here we want Excel to extract the characters located in the middle of our text in B2.

This will return “for”.

The Len Function

The LEN function returns the number of characters in the text strings.

Syntax:

LEN(text)

Parameters:

  • Text: The text we want to know the length

Example:

Step 1: Format your data.

Now if you want to know how many characters are in the text “Geeksforgeeks”. Let us follow the next step.

Step 2: We will enter =LEN(B2) in the B3 cell. Excel will count how many characters are in the text.

This will return 13.

The FIND Function

The FIND function returns the position of a given text within a text.

Syntax:

FIND(find_text, within_text, [start_num])

Parameters:

  • Find_text: The text we want to find.  
  • Within_text: The text containing our find_text.
  • Start_num (Optional): The starting position of our find_text. Default is 1.  

Example:

Step 1: Format your data.

Now if you want to find “for” in geeksforgeeks in B2. Let us follow the next step.

Step 2: We will enter =FIND(“for”,B2) in B3 cell. Here we want Excel to find “for” in our text in B2.

This will return 6 because “for” is located at character number 6 in our text.

На чтение 1 мин

Функция ПРАВСИМВ (RIGHT) используется в Excel для извлечения текста из строки с правой стороны.

Содержание

  1. Что возвращает функция
  2. Синтаксис
  3. Аргументы функции
  4. Дополнительная информация
  5. Примеры использования функции ПРАВСИМВ в Excel

Что возвращает функция

Функция возвращает заданное количество символов из текстовой строки, начиная отсчет справа.

Telegram Logo Больше лайфхаков в нашем Telegram Подписаться

Синтаксис

=RIGHT(text, [num_chars]) — английская версия

=ПРАВСИМВ(текст;[число_знаков]) — текстовая версия

Аргументы функции

  • text (текст) — текстовая строка из которой вы хотите извлечь необходимое количество букв;
  • [num_chars] ([число_знаков]) — (необязательно) количество букв, которое вы хотите извлечь из заданной текстовой строки. Если этот аргумент оставить пустым, то функция по умолчанию извлечет один символ.

Дополнительная информация

  • Аргумент num_chars (число_знаков) должен быть больше или равен нулю;
  • Если аргумент num_chars (число_знаков) больше чем длина всей текстовой строки, из которой вы хотите извлечь данные, то функция вернет текстовую строку целиком;
  • Пробелы считаются за символы;
  • Чтобы убрать лишние пробелы, используйте функцию СЖПРОБЕЛЫ;
  • Функция также работает не только с текстом, но и с числовыми значениями, указанными в текстовом формате.

Примеры использования функции ПРАВСИМВ в Excel

Функция RIGHT (ПРАВСИМВ) в Excel

This demonstration covers how to use the LEFT and Right Functions in Excel. These are text functions. In the LEFT function, you can pull a set number of characters out of a cell into another cell starting at the leftmost point. The RIGHT function performs the same except starting at the rightmost point.

left-right-functions-featured-image

Both functions are related to the MID function, which we covered back in September. At the time, one of our customers asked for a demo on the MID function. Since then, we’ve had several follow up requests on the LEFT and RIGHT.

For today’s demonstration, we will be using the following spreadsheet:

left-right-functions-image-1

In this example, Column A contains a 6-digit number hyphenated with a 4-digit number. The 6-digit number is the order number and the 4 digit is the client ID. Your job is to separate the order number and client ID into Columns C and E, respectively.

How is this done?

For the order number, we will use the LEFT function. We know the code is 6 digits, so we have the number of characters. So in cell C2, you will enter the following formula:

=LEFT(A2,6)

For the client ID, we will use the RIGHT function. In cell E2, you will enter the following formula:

=RIGHT(A2,4)

left-right-functions-demo-gif

LEFT Function Syntax:

=LEFT(Destination Cell, Number of Characters)

This tells Excel: Starting on the left of this specified cell, copy to this many characters.

RIGHT Function Syntax:

=RIGHT(Destination Cell, Number of Characters)

This tells Excel: Starting on the right of the specified cell, copy to this many characters.

As you can see in the above demonstration, once the functions have been entered, they can be copied all the way down to finish filling in the data.

We at Learn Excel Now hope you feel comfortable using the RIGHT and LEFT functions.

Like Learn Excel Now? Follow us on social media and share our content with your networks! And don’t forget to sign up for the Newsletter.

Kevin – Learn Excel Now

Извлечение (вырезание) части строки с помощью кода VBA Excel из значения ячейки или переменной. Функции Left, Mid и Right, их синтаксис и аргументы. Пример.

Эта функция извлекает левую часть строки с заданным количеством символов.

Синтаксис функции Left:

Left(строка, длина)

  • строка — обязательный аргумент: строковое выражение, из значения которого вырезается левая часть;
  • длина — обязательный аргумент: числовое выражение, указывающее количество извлекаемых символов.

Если аргумент «длина» равен нулю, возвращается пустая строка. Если аргумент «длина» равен или больше длины строки, возвращается строка полностью.

Функция Mid

Эта функция извлекает часть строки с заданным количеством символов, начиная с указанного символа (по номеру).

Синтаксис функции Mid:

Mid(строка, начало, [длина])

  • строка — обязательный аргумент: строковое выражение, из значения которого вырезается часть строки;
  • начало — обязательный аргумент: числовое выражение, указывающее положение символа в строке, с которого начинается извлекаемая часть;
  • длина — необязательный аргумент: числовое выражение, указывающее количество вырезаемых символов.

Если аргумент «начало» больше, чем количество символов в строке, функция Mid возвращает пустую строку. Если аргумент «длина» опущен или его значение превышает количество символов в строке, начиная с начального, возвращаются все символы от начальной позиции до конца строки.

Функция Right

Эта функция извлекает правую часть строки с заданным количеством символов.

Синтаксис функции Right:

Right(строка, длина)

  • строка — обязательный аргумент: строковое выражение, из значения которого вырезается правая часть;
  • длина — обязательный аргумент: числовое выражение, указывающее количество извлекаемых символов.

Если аргумент «длина» равен нулю, возвращается пустая строка. Если аргумент «длина» равен или больше длины строки, возвращается строка полностью.

Пример

В этом примере будем использовать все три представленные выше функции для извлечения из ФИО его составных частей. Для этого запишем в ячейку «A1» строку «Иванов Сидор Петрович», из которой вырежем отдельные компоненты и запишем их в ячейки «A2:A4».

Sub Primer()

Dim n1 As Long, n2 As Long

Range(«A1») = «Иванов Сидор Петрович»

‘Определяем позицию первого пробела

n1 = InStr(1, Range(«A1»), » «)

‘Определяем позицию второго пробела

n2 = InStr(n1 + 1, Range(«A1»), » «)

‘Извлекаем фамилию

Range(«A2») = Left(Range(«A1»), n1 1)

‘Извлекаем имя

Range(«A3») = Mid(Range(«A1»), n1 + 1, n2 n1 1)

‘Извлекаем отчество

Range(«A4») = Right(Range(«A1»), Len(Range(«A1»)) n2)

End Sub

На практике часто встречаются строки с лишними пробелами, которые необходимо удалить перед извлечением отдельных слов.

Excel is mostly about numerical, however, we often have data of text data type. Here are a few functions we should know to handle text data.

  • LEFT
  • RIGHT
  • MID
  • LEN
  • FIND

The LEFT function

The LEFT function returns a given text from the left of our text string based on the number of characters specified.

Syntax:

LEFT(text, [num_chars])

Parameters:

  • Text: The text we want to extract from.  
  • Num_chars (Optional): The number of characters you want to extract. Default num_chars is 1 and the number must be a positive number that is greater than zero.  

Example:

Step 1: Format your data.

Now if you want to get the first “Geeks” from “Geeksforgeeks” in B2. Let us follow the next step.

Step 2: We will enter =LEFT(B2,5) in the B3 cell. Here we want Excel to extract the first 5 characters from the left side of our text in B2.

This will return “Geeks”.

The RIGHT Function

The RIGHT function returns a given text from the left of our text string based on the number of characters specified.

Syntax:

RIGHT(text, [num_chars])

Parameters:

  • Text: The text we want to extract from.  
  • Num_chars (Optional): The number of characters you want to extract. Default num_chars is 1 and the number must be a positive number that is greater than zero.  

Example:

Step 1: Format your data.

Now if you want to get the last geeks from “Geeksforgeeks” in B2. Let us follow the next step.

Step 2: We will enter =RIGHT(B2,5) in the B3 cell. Here we want Excel to extract the last 5 characters from the right side of our text in B2.

This will return “geeks”.

The MID function

The MID function returns the text from any middle part of our text string based on the starting position and number of characters specified.

Syntax:

MID(text, start_num, num_chars)

Parameters:

  • Text: The text we want to extract from.  
  • start_num: The starting number of the first character from the text we want to extract.
  • Num_chars: The number of characters you want to extract.

Example:

Step 1: Format your data.

Now if you want to get the character “for” which is located in the middle of our text “Geeksforgeeks” in B2. Let us follow the next step.

Step 2: We will enter =MID(B2,5,3) in the B3 cell. Here we want Excel to extract the characters located in the middle of our text in B2.

This will return “for”.

The Len Function

The LEN function returns the number of characters in the text strings.

Syntax:

LEN(text)

Parameters:

  • Text: The text we want to know the length

Example:

Step 1: Format your data.

Now if you want to know how many characters are in the text “Geeksforgeeks”. Let us follow the next step.

Step 2: We will enter =LEN(B2) in the B3 cell. Excel will count how many characters are in the text.

This will return 13.

The FIND Function

The FIND function returns the position of a given text within a text.

Syntax:

FIND(find_text, within_text, [start_num])

Parameters:

  • Find_text: The text we want to find.  
  • Within_text: The text containing our find_text.
  • Start_num (Optional): The starting position of our find_text. Default is 1.  

Example:

Step 1: Format your data.

Now if you want to find “for” in geeksforgeeks in B2. Let us follow the next step.

Step 2: We will enter =FIND(“for”,B2) in B3 cell. Here we want Excel to find “for” in our text in B2.

This will return 6 because “for” is located at character number 6 in our text.

Понравилась статья? Поделить с друзьями:
  • Функции excel ячейка константа
  • Функции excel это специальные
  • Функции excel эта неделя
  • Функции excel числа текст дата
  • Функции excel для аналитиков