Ever wondered how your colleague quickly generated the pivot tables, graphs, or used text/string related functions in excel?
It’s easy, it’s just a matter of knowing how it works.
I will walk you through extremely useful excel functions required quite frequently while working on excel data. And these are must-know functions for every engineer.
In this post, I will cover string or text related excel functions. I have grouped related functions and hence will be easier to understand.
Functionality: This function removes leading and trailing spaces from the text.
How-to- If you want to get rid of the leading and trailing spaces in string ” example “, you can use trim function.
(Note spaces in the beginning and end of string).
As shown above, trim function returns a string without the spaces at the beginning and end of the string.
Note: It will not remove the spaces within the words.
eg trim(“hello world”) will NOT return “helloworld”
Quite handy function! If you know this function, you can use it in conjunction with other functions as well, which I will explain later here.
Functionality – This function returns the length of the string ie number of characters in the string.
How-to-If you want to check the length of text “example” in cell A2 as shown in below, use the function Len.
Note: If your string has space in the beginning and/or at the end of the string, it will be counted in total length.
eg len(“ example ”) =10 because there is a space in beginning and end of the string.
How to get rid of this problem if you already have such spaces in string? Let’s use the trim function we learnt just now.
Awesome, it trimmed the string first and then calculated the length of the string.
Always remember, inner functions are executed first and then outer functions.
3. Left, Right, Mid:
These functions are used if you want to extract certain number of characters from the text in excel cells.
Functionality: Left function returns mentioned number characters from left side of the text.
Functionality: Right function returns mentioned number of characters from right side of the string
Syntax- right (text,num_chars)
Functionality: mid function returns a specific number of characters from a text string, starting at the position you specify, based on the number of characters you specify.
4. Upper, Lower, Proper Case:
These functions change the case of the text.
Functionality: Upper function converts the text in upper case
Functionality: Lower function converts the text in lower case
Functionality: Proper function converts first letter of each word in text in capital letter.
5. Replace and Substitute:
These functions are used to change certain parts of the text.
Functionality: Replace function replaces part of a text string based on the number of characters you specify, with a different text string.
Syntax: replace (old_text,start_num,num_chars,new_text)
To use this function, you need to precisely know starting number of characters to be replaced. But to replace the value in text without knowing the starting number, “substitute” function can be used.
Functionality: This function is used to substitutes part of the old text to new text mentioned.
Syntax: substitute (text,old_text,new_text,instance_num)
These are used to search position of substring in the text.
Functionality: Finds one text value within another (not case-sensitive)
Syntax: search (find_text, within_text, [start_num])
Start_num is optional.
- You can use the wildcard characters — the question mark (?) and asterisk (*) — in the find_text argument. A question mark matches any single character;
- an asterisk matches any sequence of characters.
- If you want to find an actual question mark or asterisk, type a tilde (~) before the character.
- If the value of find_text is not found, the #VALUE! error value is returned.
Functionality: Finds one text value within another (case-sensitive)
- FIND is case sensitive and don’t allow wildcard characters. If you don’t want to do a case sensitive search or use wildcard characters, you can use SEARCH.
- If find_text is “” (empty text), FIND matches the first character in the search string (that is, the character numbered start_num or 1).
- Find_text cannot contain any wildcard characters.
Functionality: Another simple text function to join several text items into one text item
Syntax: concatenate(text1, [text2], …)
Small tricks save time and improve performance!
Stay tuned to learn the pivot tables, graphs in my following post.
If you are struggling with any of these functions, do send me an e-mail, I’ll get back to you and help to solve it.