CBA Excel 11 Text Functions
CBA Excel 11 Text Functions
Lecture 11
CBA
TEXT DATA
2
TEXT / STRING / CHARACTER
The following three terms all used to refer to "text" data. All three terms
mean the same thing.
– text data
– string data
– character data
This presentation will generally use the term "text data" but you should
be familiar with the terms "string data" and "character data"
3
TEXT DATA
4
TEXT ISN'T PART OF NUMERICAL CALCULATIONS
(OBVIOUSLY)
Formula to formula view (press Cntrl-`)
add up all
numbers in
column C
(Same
Spreadsheet)
values view (press Cntrl-`)
Text data in
C1 is not
included in the
Sum
5
TEXT FUNCTIONS
6
TEXT FUNCTIONS
Many functions are used to manipulate text values.
The following are only some of them
right( ) Trim ()
left( ) Choose ()
mid( ) Substitute()
concatenate( )
lower( )
upper( )
len( )
7
RIGHT, LEFT AND MID FUNCTIONS
8
RIGHT FUNCTION
9
RIGHT ( <TEXT>,
<NUMCHARACTERS>)
Formula View
Values View
10
RIGHT – NUMCHARACTERS IS
OPTIONAL
The <numCharacters> parameter in the RIGHT function is optional. If you don’t specify it the default is 1 (one).
Formula View
11
LEFT
12
MID ( <TEXT>, <STARTPOSITION> ,
<NUMCHARACTERS>)
MID is used to get values from the middle of some text.
13
EXAMPLE: MID ( <TEXT>, <STARTPOSITION> ,
<NUMCHARACTERS>)
This example extracts the second through the fourth
characters from the original text value:
Formula View
Values View
14
TRIM FUNCTION
• Removes all spaces from text except for single spaces between words. Use TRIM on text that you
have received from another application that may have irregular spacing.
• TRIM strips extra spaces from text, leaving only single spaces between words and no space
characters at the start or end of the text.
• TRIM is useful when cleaning up text that has come from other applications or environments.
Syntax: The syntax for the TRIM function in Microsoft Excel is: TRIM( text )
Parameters or Arguments: text (The text value to remove the leading and trailing spaces from.)
Purpose
Get the location of text in a string
Return value
A number representing the location of find_text.
Syntax
=SEARCH (find_text, within_text, [start_num])
USAGE NOTES
Use the SEARCH function to get the location of one text string inside another.
SEARCH returns the position of the first character of find_text inside within_text.
Unlike FIND, SEARCH allows the use of wildcards, and is not case-sensitive.
SEARCH allows the wildcard characters question mark (?) and asterisk (*), in
find_text.
The ? matches any single character and the * matches any sequence of characters.
To find a literal ? or *, use a tilde (~) before the character, i.e. ~* and ~?.
CONCATENATION
( & ) AND
CONCATENATE FUNCTION
21
CONCATENATION (&)
Use & to combine (or concatenate) two different text values
Formula View
Values View
Formula View
Values View
23
CONCATENATION WITH "LITERAL"
VALUES
You can also concatenate "literal" values.
You must include the literal values inside quotes
For example to display spaces in the "full name" in the previous example
you could use the following formula. Each space that you want to
display must be included in quotes.
24
CONCATENATING SPACES - EXAMPLE
You can concatenate spaces into a formula
Formula View
25
LEFT( ) WITH & IN SAME FORMULA
You can combine the results of different function calls with concatenation.
Formula View
Values View
26
PUTTING IT ALL TOGETHER
In this example we concatenate periods into the initials.
Formula View
Values View
=A1&B1&C1
=CONCATENATE(A1,B1,C1)
28
MORE TEXT FUNCTIONS:
LOWER
UPPER
LEN
29
LOWER ( <TEXTVALUE> )
UPPER ( <TEXTVALUE> )
LOWER converts text to lower case.
UPPER converts text to upper case.
Example:
Formula View
Values View
30
LEN ( <TEXTVALUE> )
LEN returns a numeric value equal to the number of character in a text value (i.e. the “length” of the
text value).
Spaces ARE included in the length.
Example
Formula View
Values View 31
EXCEL SUBSTITUTE FUNCTION
Summary
The Excel SUBSTITUTE function replaces text in a given string by matching. For example
=SUBSTITUTE("952-455-7865","-","") returns "9524557865"; the dash is
stripped. SUBSTITUTE is case-sensitive and does not support wildcards.
Purpose
Replace text based on content
Return value
The altered text.
EXCEL SUBSTITUTE FUNCTION
Syntax
=SUBSTITUTE (text, old_text, new_text, [instance])
Arguments
text - The text to change.
old_text - The text to replace.
new_text - The text to replace with.
instance - [optional] The instance of old_text to replace
with new_text. Optional; if not supplied, all
instances of old_text are replaced with new_text.
Summary
The Excel SUBSTITUTE function replaces text in a given string by matching. For
example =SUBSTITUTE("952-455-7865","-","") returns "9524557865"; the dash is
stripped. SUBSTITUTE is case-sensitive
CONVERTING NUMERIC VALUE'S INTO
WORDS
=CHOOSE(C6,"One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten")&"Taka"
34
TEXT TO COLUMNS
Step 1
Step 1 : Select the range with full names.
Step 2 : On the Data tab,
in the Data Tools group, click Text to Columns.
Step 2
STEP 3 : CHOOSE DELIMITED AND
CLICK NEXT.
STEP 4 : 4. CLEAR ALL THE CHECK BOXES UNDER DELIMITERS
EXCEPT FOR THE COMMA AND SPACE CHECK BOX.
STEP 5 : CLICK FINISH.