Excel Text Functions
CONCATENATE (or CONCAT)
Syntax: CONCATENATE(text1, [text2], ...)
Example:
=CONCATENATE("Hello", " ", "World") // Returns "Hello World"
=CONCATENATE(A1, " ", B1) // Concatenates the contents of cells A1 and B1 with a space in between.
LEFT
Syntax: LEFT(text, num_chars)
Example:
=LEFT("Excel Functions", 5) // Returns "Excel"
=LEFT(A1, 3) // Returns the leftmost 3 characters from the text in cell A1.
RIGHT
Syntax: RIGHT(text, num_chars)
Example:
=RIGHT("Excel Functions", 8) // Returns "Functions"
=RIGHT(A1, 6) // Returns the rightmost 6 characters from the text in cell A1.
MID
Syntax: MID(text, start_num, num_chars)
Example:
=MID("Excel Functions", 7, 9) // Returns "Functions"
=MID(A1, 2, 4) // Returns 4 characters from cell A1, starting at the 2nd character.
LEN
Syntax: LEN(text)
Example:
=LEN("Excel") // Returns 5, as "Excel" has 5 characters.
=LEN(A1) // Returns the number of characters in cell A1.
FIND
Syntax: FIND(find_text, within_text, [start_num])
Example:
=FIND("lo", "Hello") // Returns 3, as "lo" starts at the 3rd position in "Hello."
=FIND("apple", A1, 2) // Searches for "apple" in cell A1 starting at the 2nd position.
REPLACE
Syntax: REPLACE(old_text, start_num, num_chars, new_text)
Example:
=REPLACE("Hello World", 7, 5, "Excel") // Returns "Hello Excel"
=REPLACE(A1, 2, 3, "New") // Replaces characters in cell A1 starting at the 2nd position with "New."
UPPER, LOWER, and PROPER
These functions are used to change the case of text.
• UPPER(text) converts text to uppercase.
• LOWER(text) converts text to lowercase.
• PROPER(text) capitalizes the first letter of each word.
=UPPER("hello") // Returns "HELLO"
=LOWER("WORLD") // Returns "world"
=PROPER("this is a test") // Returns "This Is A Test"
TRIM
Syntax: TRIM(text)
Example:
=TRIM(" Excel ") // Removes leading and trailing spaces, resulting in "Excel"
=TRIM(A1) // Removes extra spaces from the text in cell A1.
SUBSTITUTE
Syntax: SUBSTITUTE(text, old_text, new_text, [instance_num])
Example:
=SUBSTITUTE("This is a test.", "is", "was") // Returns "Thwas was a test."
=SUBSTITUTE(A1, "apple", "orange", 2) // Replaces the second occurrence of "apple" with "orange" in cell A1.
TEXT
Syntax: TEXT(value, format_text)
Example:
=TEXT(TODAY(), "dd-mmm-yyyy") // Returns the current date in the format "28-Sep-2023".
=TEXT(A1, "0.00") // Formats the number in cell A1 with two decimal places.
CONVERT
Syntax: CONVERT(text, from_unit, to_unit)
Example:
=CONVERT("25.4", "mm", "in") // Converts 25.4 millimeters to inches, returning approximately 1.
=CONVERT(A1, "km", "mi") // Converts the value in cell A1 from kilometers to miles.
EXACT
Syntax: EXACT(text1, text2)
Example:
=EXACT("Excel", "excel") // Returns FALSE because the two strings are not exactly the same case-sensitive.
=EXACT(A1, B1) // Checks if the text in cells A1 and B1 are exactly the same.
SEARCH
Syntax: SEARCH(find_text, within_text, [start_num])
Example:
=SEARCH("Excel", "Microsoft Excel is powerful") // Returns 11, as "Excel" starts at the 11th position.
=SEARCH("dog", A1, 3) // Searches for "dog" in cell A1 starting at the 3rd position.
CLEAN
Syntax: CLEAN(text)
Example:
=CLEAN("This is a" & CHAR(7) & "test.") // Removes non-printable characters and returns "This is a test."
=CLEAN(A1) // Cleans the text in cell A1 from non-printable characters.
CHAR
Syntax: CHAR(number)
Example:
=CHAR(65) // Returns "A" because the character code 65 corresponds to the letter "A" in the ASCII character set.
=CHAR(A1) // If cell A1 contains the value 72, it will return "H".
UNICODE
Syntax: UNICODE(text)
=UNICODE("A") // Returns 65 because "A" has a Unicode value of 65.
=UNICODE(A1) // If cell A1 contains the text "H", it will return 72.
=UNICODE("こんにちは") // Returns 12371 because it represents the Unicode value of the first character "こ" in
the Japanese greeting.