You are on page 1of 18

Part- A: Spreadsheet (Excel) Lab 4.

Contents
1.LEFT Function.....................................................................................................................................1
How to Use the LEFT Function with a Defined Length of Characters.............................3
How to use the LEFT Function on a Range of Cells............................................................4
2. Excel MID Function Syntax.................................................................................................................6
Examples......................................................................................................................................6
3.Excel LEN Function Syntax..................................................................................................................7
Excel LEN Function Examples..........................................................................................................7
4.RIGHT Function...................................................................................................................................8
How to use the RIGHT function with a defined length of characters..........................10
How to use the RIGHT function used on a range of cells................................................................12
5.SUBSTITUTE Function.......................................................................................................................14
Examples...................................................................................................................................14
6.LEN Function.....................................................................................................................................15
Syntax.............................................................................................................................................15
Examples...................................................................................................................................15
7.SEARCH Function..............................................................................................................................16
Purpose.........................................................................................................................................16
Return value.................................................................................................................................16
Syntax............................................................................................................................................16
Basic Example.........................................................................................................................16
TRUE or FALSE result...........................................................................................................17

1.LEFT Function
The LEFT function is used to retrieve a chosen amount of characters,
counting from the left side of an Excel cell. The chosen number has to be
greater than 0 and is set to 1 by default.

It is typed =LEFT
If you want to use the function on a single cell, write:

=LEFT(cell)

If you want to use the function on a range of cells, write:

=LEFT(start cell:end cell)

Step 1) Start the LEFT function

1. Select a cell E2
2. Type =LEFT
3. Double click the LEFT command

Step 2) Enter values to the LEFT function

4. Select a cell (A2)


5. Hit enter
How to Use the LEFT Function with a Defined Length
of Characters
Learn to use =LEFT to get more than one character.

Step 1) Start the LEFT function

1. Select a cell E2
2. Type =LEFT
3. Double click the LEFT command
Step 2) Select cells and set the number of characters

4. Enter the cell name (A2) and define the length of characters you want
to retrieve, using a , as a delimiter (A2,3)
5. Hit enter

The function returns the first 3 characters from cell A2.


How to use the LEFT Function on a Range of Cells
Step 1) Start the LEFT function

1. Select a cell E2
2. Type =LEFT
3. Double click the LEFT command

Step 2) Select cells and number of characters

4. Select the cells (A2:A4) and define the length of characters you want to
retrieve, using a , as a delimiter (A2:A4,3)
5. Hit enter

The function returns the first 3 characters from each cell within the
range A2:A4.
2. Excel MID Function Syntax

The MID function in Excel returns text of a certain length from the inside of
a string (neither the leftmost nor the rightmost). The MID function takes
three arguments:

=MID(text, start, length)

 text - The original string of text, either as a cell reference or as a string enclosed
in quotes
 start - The number of the starting character of the desired text (the first character
is 1, the second is 2, and so on)
 length - The number of characters to extract from the original string

Examples
=MID("Some text", 3, 5)

The function above returns the string "me te". See explanation below:

=MID("Some text")
------123456789
--------12345

We start counting at character 3 of the original string, and take five


characters (including the space) so that the function returns "me te".

Suppose cell A1 contained the text "Excel Exercises". The


function =MID(A1, 3, 7) would return "cel Exe" - see below.

=MID(A3, 2, 5)

This MID formula would return "ennif".

Jennifer
12345678
-12345

=MID(D1, 2, 2)

This MID function would return "AL".

SALES
12345
--

3.Excel LEN Function Syntax

The LEN function takes one argument (value within the parenthesis) which
is typically text, but could also be numerical or a date value. LEN then
returns the length, in characters, of the argument. LEN includes characters
such as spaces and punctuation in the character count. LEN can take a cell
reference which contains text or a string of text enclosed in quotes as its
argument.

=LEN("Some text")

The function above returns 9 because the string of text comprises 9


characters. See below:

=LEN("Some text")
------123456789

Excel LEN Function Examples

=LEN(A2)

The LEN formula above would return 3, as shown below:

Bob
123
=LEN(A3)

This LEN formula would return 8. Why? The string "Jennifer" contains 8
characters.

Jennifer
12345678

The LEN function can also be used on numbers in Excel.

=LEN(C2)

This formula would return 2.

32
12

4.RIGHT Function
The RIGHT function is used to retrieve a chosen amount of characters,
counting from the right side of an Excel cell. The chosen number has to be
greater than 0 and is set to 1 by default.

It is typed =RIGHT

=RIGHT(cell)

If you want to use the function on a range of cells, write:

=RIGHT(start cell:end cell).

To retrieve values from the right side of an Excel cell, use RIGHT.

Step 1) Start the RIGHT function

1. Select a cell E2
2. Type =RIGHT
3. Double click the RIGHT command

Step 2) Enter values to the RIGHT function

4. Select a cell (A2)


5. Hit enter
=RIGHT(A2) uses the default funcion of RIGHT and retrieves the last symbol
from the A2 cell.

How to use the RIGHT function with a defined length


of characters
Step 1) Start the RIGHT function

1. Select a cell E2
2. Type =RIGHT
3. Double click the RIGHT command

Step 2) Select cells and set the number of characters

4. Enter the cell name (A2) and define the length of characters you want
to retrieve, using a , as a delimiter (A2,3)
5. Hit enter

The function returns the last 3 symbols from cell A2.


How to use the RIGHT function used on a range of cells
Step 1) Start the RIGHT function

1. Select a cell E2
2. Type =RIGHT
3. Double click the RIGHT command
Step 2) Select cells and number of characters

4. Select the cells (A2:A4) and define the length of characters you want to
retrieve, using a , as a delimiter (A2:A4,3)
5. Hit enter

The function returns the last 3 symbols from each cell within the
range A2:A4.
5.SUBSTITUTE Function
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.

Syntex.

=SUBSTITUTE(text,old_text,new_text,[instance])

 text - The text to change.

 old_text - The text to replace.

 new_text - The text to replace with.

 instance - [optional] The instance to replace. If not supplied, all instances are
replaced.

Examples
Below are the formulas used in the example shown above:

=SUBSTITUTE(B5,"t","b") // replace all t's with b's


=SUBSTITUTE(B6,"t","b",1) // replace first t with b
=SUBSTITUTE(B7,"cat","dog") // replace cat with dog
=SUBSTITUTE(B8,"&","") // replace # with nothing
=SUBSTITUTE(B9,"-",", ") // replace hyphen with comma

6.LEN Function
The Excel LEN function returns the length of a given text string as the number of characters. LEN will
also count characters in numbers, but number formatting is not included.

Syntax
=LEN(text)

Examples
LEN returns the count of characters in a text string:

=LEN("apple") // returns 5

The LEN function often appears in other formulas that manipulate text in some way.
For example, it can be used with the RIGHT and FIND functions to extract text to the
right of a given character:

=RIGHT(A1,LEN(A1)-FIND(char,A1)) // get text to right of char


7.SEARCH Function

Purpose
Get the location of substring in a string

Return value
A number representing the location of substring

Syntax
=SEARCH(find_text,within_text,[start_num])

 find_text - The substring to find.


 within_text - The text to search within.
 start_num - [optional] Starting position. Optional, defaults to 1.

Basic Example
The SEARCH function is designed to look inside a text string for a specific
substring. If SEARCH finds the substring, it returns a position of the substring in the
text as a number. If the substring is not found, SEARCH returns a #VALUE error. For
example:

=SEARCH("p","apple") // returns 2
=SEARCH("z","apple") // returns #VALUE!
TRUE or FALSE result
To force a TRUE or FALSE result, nest SEARCH inside the ISNUMBER function.
ISNUMBER returns TRUE for numbers and FALSE for anything else. If SEARCH
finds the substring, it returns the position as a number, and ISNUMBER returns
TRUE:

=ISNUMBER(SEARCH("p","apple")) // returns TRUE


=ISNUMBER(SEARCH("z","apple")) // returns FALSE

8.ISNUMBER Function

Purpose
Test for numeric value

Return value
A logical value (TRUE or FALSE)

Syntax
=ISNUMBER(value)

 value - The value to check.

Examples
The ISNUMBER function returns TRUE if value is numeric:

=ISNUMBER("apple") // returns FALSE


=ISNUMBER(100) // returns TRUE
If cell A1 contains the number 100, ISNUMBER returns TRUE:

=ISNUMBER(A1) // returns TRUE


If a cell contains a formula, ISNUMBER checks the result of the formula:

=ISNUMBER(2+2) // returns TRUE


=ISNUMBER(2^3) // returns TRUE
=ISNUMBER(10 &" apples") // returns FALSE

Count numeric values


To count cells in a range that contain numbers, you can use the SUMPRODUCT
function like this:

=SUMPRODUCT(--ISNUMBER(range))
The double negative coerces the TRUE and FALSE results from ISNUMBER into
1s and 0s and SUMPRODUCT sums the result.

You might also like