logo
Microsoft Excel - Interview Questions and Answers
How do you use the TEXT, LEFT, RIGHT, MID functions in Excel?
Using TEXT, LEFT, RIGHT, and MID Functions in Excel

These functions help manipulate and format text in Excel.


1. TEXT Function (Format Numbers as Text)

The TEXT function converts a number into a formatted text string.

Syntax :
=TEXT(value, format_text)
  • value → The number or cell to format.
  • format_text → The format to apply (e.g., "MM/DD/YYYY", "$#,##0.00").
Examples :
  • Format a date as "Month Day, Year":

    =TEXT(A1, "MMMM DD, YYYY")
    
    • If A1 = 01/01/2024, result → "January 01, 2024"
  • Format a number as currency:

    =TEXT(A1, "$#,##0.00")
    
    • If A1 = 1234.5, result → "$1,234.50"

2. LEFT Function (Extract Characters from the Left)

The LEFT function returns a specific number of characters from the beginning (left side) of a text string.

Syntax :
=LEFT(text, num_chars)
  • text → The text or cell to extract from.
  • num_chars → Number of characters to extract.
Example :
  • Extract the first 3 characters of "Excel":

    =LEFT("Excel", 3)
    

    Result: "Exc"

  • Extract first 2 characters from A1:

    =LEFT(A1, 2)
    
    • If A1 = "Product123", result → "Pr"

3. RIGHT Function (Extract Characters from the Right)

The RIGHT function returns a specific number of characters from the end (right side) of a text string.

Syntax :
=RIGHT(text, num_chars)
Example :
  • Extract the last 3 digits of a phone number ("123456789"):

    =RIGHT("123456789", 3)
    

    Result: "789"

  • Extract the last 4 characters from A1:

    =RIGHT(A1, 4)
    
    • If A1 = "Invoice2024", result → "2024"

4. MID Function (Extract Characters from the Middle)

The MID function extracts a substring from the middle of a text, based on a start position and length.

Syntax :
=MID(text, start_num, num_chars)
  • text → The text or cell to extract from.
  • start_num → Position of the first character to extract.
  • num_chars → Number of characters to extract.
Example :
  • Extract "cro" from "Microsoft":

    =MID("Microsoft", 3, 3)
    

    Result: "cro"

  • Extract 5 characters starting from the 4th position in A1:

    =MID(A1, 4, 5)
    
    • If A1 = "Product123", result → "duct1"

Comparison Table
Function Purpose Example Result
TEXT Format numbers as text =TEXT(1234.5, "$#,##0.00") "$1,234.50"
LEFT Extract from the left =LEFT("Excel", 3) "Exc"
RIGHT Extract from the right =RIGHT("Excel", 2) "el"
MID Extract from the middle =MID("Microsoft", 3, 3) "cro"