excel for mac text functions - university of brighton documents/excel...excel for mac text functions...

22
[Type here] Excel for Mac Text Functions HOW TO CLEAN UP TEXT IN A FLASH This document looks at some of the tools available in Excel 2016 for manipulating text. It is suitable for anyone who uses Excel on a Mac for databases such as lists of contacts, students or delegates. This workbook assumes a working knowledge of Excel. A basic knowledge of using functions in Excel like SUM and COUNT would be an advantage. You can download the exercise files for this workbook from our website www.brighton.ac.uk/is/docs with the course code is141e. Last updated 09 th January 2017 This document and other Information Services documents are held online on our website: https://staff.brighton.ac.uk/is

Upload: others

Post on 13-Sep-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Excel for Mac Text Functions - University of Brighton Documents/Excel...Excel for MAC Text Functions Printed Monday, 09 January 2017 Page | 3 Find and Replace to update multiple entries

[Type here]

Excel for Mac Text

Functions HOW TO CLEAN UP TEXT IN A FLASH

This document looks at some of the tools available in Excel

2016 for manipulating text.

It is suitable for anyone who uses Excel on a Mac for

databases such as lists of contacts, students or delegates.

This workbook assumes a working knowledge of Excel. A basic

knowledge of using functions in Excel like SUM and COUNT

would be an advantage.

You can download the exercise files for this workbook from

our website www.brighton.ac.uk/is/docs with the course code

is141e.

Last updated

09th January 2017

This document and other Information Services documents are

held online on our website: https://staff.brighton.ac.uk/is

Page 2: Excel for Mac Text Functions - University of Brighton Documents/Excel...Excel for MAC Text Functions Printed Monday, 09 January 2017 Page | 3 Find and Replace to update multiple entries

University of Brighton Information Services

Page | 2 Last Updated 15th July 2015

Contents

Find and Replace to update multiple entries in one hit ..................................... 3

Autofill to copy a formula down a column ......................................................... 4

Splitting one column of text into two or more columns (Convert Text to

Columns) ................................................................................................................ 5

Merging columns into one (CONCATENATE) .................................................. 7

Paste Values to avoid errors when deleting columns ....................................... 8

Changing the case of text (PROPER, UPPER & LOWER) ..............................10

Copying part of a column of text ......................................................................13

LEFT function to extract text from the left of a cell ..............................................13

RIGHT function to extract text from the right of a cell ..........................................14

MID function to extract text from the middle of a cell ...........................................14

Removing spaces (TRIM function) ..................................................................15

Duplicate entries .............................................................................................17

Conditional formatting to identify duplicates (Excel 2011 only) ....................17

Remove Duplicates (Excel 2011 only) .........................................................18

Use a formula to identify duplicate entries ...................................................19

Copy & Transpose a column to a row ..........................................................22

Page 3: Excel for Mac Text Functions - University of Brighton Documents/Excel...Excel for MAC Text Functions Printed Monday, 09 January 2017 Page | 3 Find and Replace to update multiple entries

Excel for MAC Text Functions

Printed Monday, 09 January 2017 Page | 3

Find and Replace to update multiple entries in one

hit

If you need to replace all instances of a certain string of text with another, use find

and replace:

Click on Edit >>Find>>Replace on the menu bar.

Click on Replace

Type the text that you want to replace in the Find what box

Type the text that you want to replace it with in the Replace with box.

Click on Replace all.

Exercise A Using Find and Replace

Open up the exercise file Find_Replace.xlsx. This is a membership list.

For this exercise, imagine that we have changed the branding of our membership

types. We have renamed our Life membership to now be called Super. We want to

therefore replace any instances of the word Life with the word Super.

Select the column containing the membership types by clicking on the column

header for column F.

Click on Edit >>Find>>Replace on the menu bar.

Type Life in the Find what box. This asks

Excel to find all instances of the word Life.

Type Super in the Replace with box. This

tells Excel you want to replace the word

Life with the word Super.

Click on Replace all.

Excel will tell you how many replacements it has made. Click OK to close the

message.

Click Close to close the Find and Replace window.

Page 4: Excel for Mac Text Functions - University of Brighton Documents/Excel...Excel for MAC Text Functions Printed Monday, 09 January 2017 Page | 3 Find and Replace to update multiple entries

University of Brighton Information Services

Page | 4 Last Updated 15th July 2015

Autofill to copy a formula down a column

When you want a formula to appear in every cell within a column:

Build the formula in the first cell in the column

Use autofill to copy the formula down the column

We will use the autofill technique throughout this booklet.

To use autofill:

Select the cell(s) you want to copy. The fill handle will appear

at the bottom right of the selection.

Point at the fill handle until it becomes a cross.

Click and drag to copy the data OR Double-click to autofill all rows.

Click on to change the type of fill (series, copy, formula only etc.)

Double click on one of the newly-populated cells within the column to check

that the copied cell references are correct.

Exercise B Using Autofill

Open up the exercise file Autofill.xlsx and double click on cell I2.

Cell I2 contains a formula to calculate the monthly payment for that row, based on

the annual fee in column G. We are going to copy this formula down the row to

automatically calculate the monthly fee for each row using the same formula.

Press Esc on your keyboard to exit the function.

Select cell I2. The fill handle will appear at the bottom right of

the cell.

Point at the fill handle until it becomes a black cross.

Click and drag down column I to copy the data OR double-click to autofill all

rows in the column. Double-click only works if the column to the left has data in

every cell.

Double click on one of the newly populated cells to check the cell references

for that row. When you have finished checking, press Esc on your keyboard to

exit the function.

Page 5: Excel for Mac Text Functions - University of Brighton Documents/Excel...Excel for MAC Text Functions Printed Monday, 09 January 2017 Page | 3 Find and Replace to update multiple entries

Excel for MAC Text Functions

Printed Monday, 09 January 2017 Page | 5

Splitting one column of text into two or more

columns (Convert Text to Columns)

Text to Columns can be used where a common character (delimiter) separates two

or more sections of text within each cell in a column.

Common delimiters include a space, semi-colon (;) or comma (,).

Check that there are enough empty columns to the right of the column you are

going to split. You will need one column per section of text to be split, including

the original column itself. To insert an empty column if needed:

Click on the column letter of the column to the right of the column

you want to split.

On the Home ribbon find the Insert button and click the menu path

Insert >> Insert Sheet Columns

Click on the column heading of the column you want to split

Click on the on the data tab and then click on the icon Text to

Columns.

The Convert Text to Columns wizard

appears.

For sections of text separated by commas,

spaces, semi-colons or other characters,

check that the Delimited option is selected

and click Next

In the Delimiters section, choose what

character separates the two sections of text in

your column. For instance, in the example at

the top of the page, a space separates the first

name and the surname in column B. So a

space is the delimiter.

Page 6: Excel for Mac Text Functions - University of Brighton Documents/Excel...Excel for MAC Text Functions Printed Monday, 09 January 2017 Page | 3 Find and Replace to update multiple entries

University of Brighton Information Services

Page | 6 Last Updated 15th July 2015

If the character separating your text is not in the list, choose Other and

then type the character used as the delimiter in the box as shown on the

left and click Next.

In the Data preview at the bottom of the window,

check that the proposed split is what you are

expecting and then click on Finish.

Exercise C Using Text to Columns

Open up the exercise file Text_to_Columns.xlsx. In

this exercise we are going to split the Name column

into separate First Name and Surname columns.

Our Name column has 2 words in each cell, separated by a space. So:

We need 2 columns for the split (including column B itself)

The delimiter (which tells Excel where to make the split) is a space.

Insert a blank column to the right of column B.

Select column B by clicking on the column letter.

In Excel 2016, click on the data tab and then click

on the icon.

The Convert Text to Columns wizard appears.

Our text has a delimiter, so we do not change anything in the first step of the wizard, we simply click Next.

In the next step of the wizard, we must tell Excel

what the delimiter is. The default is a Tab. Our

delimiter is a space, so deselect Tab and click to

select Space.

Click Next.

Page 7: Excel for Mac Text Functions - University of Brighton Documents/Excel...Excel for MAC Text Functions Printed Monday, 09 January 2017 Page | 3 Find and Replace to update multiple entries

Excel for MAC Text Functions

Printed Monday, 09 January 2017 Page | 7

In the Data preview at the bottom of the window,

check that the proposed split is OK: check that

each name has been split as you were expecting.

Click on Finish.

Merging columns into one (CONCATENATE)

This involves three steps:

Insert a new column

In the new column, use the

CONCATENATE function to build the new string of text

Use Paste Values to strip the

CONCATENATE formula from the new

column, leaving just the string of text

(only needed if you want to delete the

original columns)

Format Example Result

=CONCATENATE(text1,

text2,…)

Where text can be:

A cell reference

Fixed text (always contained within quotation marks “”)

=CONCATENATE(B2,” “,C2) Roger

Wilson

=CONCATENATE(“Patient’s

name is”,B2,” “,C2)

Patient’s

name is

Roger

Wilson

Exercise D Using CONCATENATE

Open up the exercise file CONCATENATE_1.xlsx. In this exercise we are

going to merge the Name and Surname columns into one column.

Insert a new column to the right of column C and type Full Name as the

column heading.

In cell D2, start your CONCATENATE function by typing =CONCATENATE(

Page 8: Excel for Mac Text Functions - University of Brighton Documents/Excel...Excel for MAC Text Functions Printed Monday, 09 January 2017 Page | 3 Find and Replace to update multiple entries

University of Brighton Information Services

Page | 8 Last Updated 15th July 2015

Use your mouse to click on cell B2 and then type a comma (to say you have

finished identifying the first part of the text string). Your function will now read

=CONCATENATE(B2,

We want a space to appear between the first name and surname. To achieve

this, type “ “, Your function will now read =CONCATENATE(B2,” “, with the final

comma indicating that you have finished identifying the second part of the text

string

Use your mouse to click on cell C2. Your function will now read

=CONCATENATE(B2,” “,C2

Press ENTER on your keyboard to complete the function and copy the formula

down the column using autofill.

To enable us to delete columns B and C we will now need to Paste Values, as

explained in the next section

Paste Values to avoid errors when deleting

columns

After using a text function like CONCATENATE, we often want to delete the

columns referenced in the function, leaving just the new column containing the

result of the function. For example, in the exercise on the previous page, we may

want to delete column B (First Name) and column C (Last Name) and just leave the

new column D (Full Name).

If a text function like CONCATENATE, PROPER or LEFT references cells in other

columns, simply deleting those columns will result in an error as the text function

will no longer be able to find the cells it references.

Before we can delete the referenced columns, we must first remove any functions

that reference the columns you want to delete. To do this:

Select the column containing the text function (e.g. the CONCATENATE

function) by clicking once on the column header

PASTE

VALUES

Page 9: Excel for Mac Text Functions - University of Brighton Documents/Excel...Excel for MAC Text Functions Printed Monday, 09 January 2017 Page | 3 Find and Replace to update multiple entries

Excel for MAC Text Functions

Printed Monday, 09 January 2017 Page | 9

In Excel 2011:

Click on the Copy icon on the standard

toolbar.

Click on the drop-down arrow on the Paste

icon on the Home tab on the ribbon

Navigate down the menu to the icon called Paste

Values

This copies and pastes the column over itself. Using Paste Values pastes in just

the values (the result of the function) rather than the function itself. This removes

any references to other columns and enables you to delete the unwanted

referenced columns without any problem.

Exercise E Demonstration of what happens if we do not use Paste Values

Let’s see what happens if we just try to delete the referenced columns without using

Paste Values first of all:

Use the file from the previous exercise or open the file

CONCATENATE_2.xlsx

Double-click on cell D2 to remind yourself of its contents. The cells referenced

in columns B and C are highlighted. Press Esc on your keyboard to exit the

function.

Delete column B. Column D shows #REF! to indicate that there is a problem

with the formula contained in that column. This is because column B was

referenced by the CONCATENATE function used in that column.

Click on the menu path Edit >> Undo to back out the deletion of column B.

So simply deleting referenced columns will not work. Next, let’s see what happens if

we use a simple Copy and Paste:

Double click on cell D2 to remind yourself of its contents (a CONCATENATE

function) and then press Esc on your keyboard to exit the function.

Select column D by clicking on the column header.

Copy the column

Replace the content of column D with the copied cells

Double click on cell D2 to check its contents now. It still contains the

CONCATENATE function and the cell references. Nothing has changed. If we

delete columns B and C now we will have the same problem as before.

Page 10: Excel for Mac Text Functions - University of Brighton Documents/Excel...Excel for MAC Text Functions Printed Monday, 09 January 2017 Page | 3 Find and Replace to update multiple entries

University of Brighton Information Services

Page | 10 Last Updated 15th July 2015

Press Esc on your keyboard to exit the function.

Exercise F Using Paste Values

Here’s how to do it properly:

Select column D by clicking on the column header.

Copy the selected column (in Excel 2008, follow the menu

path Edit >> Copy, in Excel 2011 click on the Copy icon

on the standard toolbar).

Click on the drop-down arrow on the Paste icon on the

Home tab on the ribbon.

On the drop down menu select the option Paste Values

Double click on cell D2 to check its contents now. It now contains only text –

the names themselves. Paste Values has pasted the result of the

CONCATENATE function into column D, rather than the function itself.

Delete columns B and C. As column D no longer contains the CONCATENATE

function, it no longer references columns B and C and you are able to delete

them without any problem.

We will use this technique of copying a column and pasting its values back upon

itself over and over when using text functions.

Changing the case of text (PROPER, UPPER &

LOWER)

Sometimes the text in a column of text is not consistent. For instance, if an address

database has been built by people submitting a form online, some names will be

UPPER CASE, whilst others will be lower case whilst others may be a mixture of

the two. If we want to use those names for professional-looking mail-merges, we

first need to clean up the text so that it is consistent.

There are a number of text functions available for changing the case of text:

Format Example Result Notes

=PROPER(text)

Where text can be a

cell reference

=PROPER(B2) ROGER WILSON becomes Roger Wilson

roger wilson becomes Roger Wilson

Roger Wilson will stay as Roger Wilson

Useful for

lists of

names

Page 11: Excel for Mac Text Functions - University of Brighton Documents/Excel...Excel for MAC Text Functions Printed Monday, 09 January 2017 Page | 3 Find and Replace to update multiple entries

Excel for MAC Text Functions

Printed Monday, 09 January 2017 Page | 11

=UPPER(text)

Where text can be a

cell reference

=UPPER(B2) ROGER WILSON will stay as ROGER

WILSON

roger wilson becomes ROGER WILSON

Roger Wilson becomes ROGER WILSON

Useful for

post codes in

address lists

=LOWER (text)

Where text can be a

cell reference

=LOWER(B2) ROGER WILSON becomes roger wilson

roger wilson will stay as roger wilson

Roger Wilson becomes roger wilson

Useful for

email

addresses

The technique for using any of these text functions is the same:

Insert a new column

In the new column, use the relevant text function to convert the text from

another column

Use Paste Values to strip the text function from the new column, leaving

just the text itself

Delete the original columns if needed The exercises on the next page walk you through each function.

Page 12: Excel for Mac Text Functions - University of Brighton Documents/Excel...Excel for MAC Text Functions Printed Monday, 09 January 2017 Page | 3 Find and Replace to update multiple entries

University of Brighton Information Services

Page | 12 Last Updated 15th July 2015

Exercise G Using the PROPER function

This function is useful for lists of names. The first letter of each word is converted to

upper case and all other letters are converted to lower case.

Open the exercise file Case_Functions_1.xlsx

In this exercise we are going to use the PROPER function to convert the name and surnames in the list.

Insert 2 new columns to the right of column C. This should create columns D

and E as empty columns.

In cell D2, start your PROPER function by typing =PROPER(

Use your mouse to click on cell B2 (the first name). The function will now read

=PROPER(B2

Press ENTER on your keyboard to complete the function and then copy the

formula down the column using autofill.

Repeat steps 3-5, but this time convert the surnames in column C so that they

appear in column E.

Follow the Paste Values technique to delete columns B and C without losing

the text in columns D and E (see page 8)

Exercise H Using the UPPER function

This function is useful for post codes in address lists. All letters are converted to

UPPER CASE.

Continue with the exercise file Case_Functions_1.xlsx In this exercise we are going to use the UPPER function to convert the post codes in the list.

Insert a new column to the right of the Post Code column. This should create

column H as an empty column.

In cell H2, start your UPPER function by typing =UPPER(

Use your mouse to click on cell G2 (the first post code). The function will now

read =UPPER(G2

Press ENTER on your keyboard to complete the function and then copy the

formula down column H using autofill.

Follow the Paste Values technique to delete column G without losing the text

in columns H (see page 8)

Page 13: Excel for Mac Text Functions - University of Brighton Documents/Excel...Excel for MAC Text Functions Printed Monday, 09 January 2017 Page | 3 Find and Replace to update multiple entries

Excel for MAC Text Functions

Printed Monday, 09 January 2017 Page | 13

Exercise I Using the LOWER function

This function is useful for email addresses in contacts lists. All letters are converted

to lower case.

Continue with the exercise file Case_Functions_1.xlsx In this exercise we are going to use the LOWER function to convert the email addresses in the list.

In cell I2, start your LOWER function by typing =LOWER(

Use your mouse to click on cell H2 (the first email address). The function will

now read =LOWER(H2

Press ENTER on your keyboard to complete the function and then copy the

formula down column I using autofill.

Follow the Paste Values technique to delete column H without losing the text

in columns I (see page 8)

Handy Hint: If you want to change the case of text in Microsoft Word 2016

Select the text you want to change

Press the fn and SHIFT and F3 keys together:

pressing once will convert all text to UPPER CASE

pressing once again will convert all text to lower case

pressing once again will convert all text to Proper case.

This technique does not work in Outlook 2016

Copying part of a column of text

Sometimes multiple strings of text appear together in one column when you would

prefer them to be in separate columns, but there is no delimiter between the strings

of text to enable us to use Text to Columns. This can happen with codes and data

extracted from other systems.

There are a number of text functions available for extracting characters from a

string of text:

LEFT function to extract text from the left of a cell

LEFT

Page 14: Excel for Mac Text Functions - University of Brighton Documents/Excel...Excel for MAC Text Functions Printed Monday, 09 January 2017 Page | 3 Find and Replace to update multiple entries

University of Brighton Information Services

Page | 14 Last Updated 15th July 2015

The format of the function is: =LEFT(text,number_of_characters) where:

text is a cell reference

number_of_characters is the number of characters you want to copy

In cell C2 in the example above, the formula would be =LEFT(B2,4)

RIGHT function to extract text from the right of a cell

The format of the function is: =RIGHT(text,number_of_characters) where:

text is a cell reference

number_of_characters is the number of characters you want to copy

In cell E2 in the example above, the formula would be =RIGHT(B2,5)

MID function to extract text from the middle of a cell

The format of the function is: =MID(text,start_number,number_of_characters)

where:

text is a cell reference

start_number is where you want to start from (counting the number of

characters from the left of the cell)

number_of_characters is the number of characters you want to copy

In cell D2 in the example above, the formula would be =MID(B2,5,4)

We’re going to replicate the example above, splitting the EFIN code into its

component parts.

Exercise J Using the LEFT function

Open the exercise file LEFT_RIGHT_MID.xlsx

In cell C2, start your LEFT function by typing =LEFT(

Click on cell B2 and then type a comma to tell Excel that you have finished that

piece of information. Your function should now read =LEFT(B2,

Type 4 to indicate that you want to extract the first 4 characters of the text in

cell B2. Your function should now read =LEFT(B2,4

Page 15: Excel for Mac Text Functions - University of Brighton Documents/Excel...Excel for MAC Text Functions Printed Monday, 09 January 2017 Page | 3 Find and Replace to update multiple entries

Excel for MAC Text Functions

Printed Monday, 09 January 2017 Page | 15

Press ENTER on your keyboard to complete the function and then copy the

formula down the column using autofill.

Exercise K Using the RIGHT function

In cell E2, start your RIGHT function by typing =RIGHT(

Click on cell B2 and then type a comma to tell Excel that you have finished that

piece of information. Your function should now read =RIGHT(B2,

Type 5 to indicate that you want to extract the last 5 characters of the text in

cell B2. Your function should now read =RIGHT(B2,5

Press ENTER on your keyboard to complete the function and then copy the

formula down the column using autofill.

Exercise L Using the MID function

In cell D2, start your MID function by typing =MID(

Click on cell B2 and then type a comma to tell Excel that you have finished that

piece of information. Your function should now read =MID(B2,

Type 5 to indicate that you want start extracting characters from the fifth

character, counting from the left of cell B2. Your function should now read

=MID(B2,5

Type a comma to tell Excel that you have finished that piece of information.

Your function should now read =MID(B2,5,

Type 4 to indicate that you want to extract 4 characters of the text (starting

from the character identified in step 3). Your function should now read

=MID(B2,5,4

Press ENTER on your keyboard to complete the function and then copy the

formula down the column using autofill

Removing spaces (TRIM function)

Sometimes erroneous spaces within a cell will affect how well functions such as

LEFT, MID and RIGHT perform (see cell E4 in the previous exercise – a space at

the end of the text in cell B4 results in the first character being omitted, resulting in

1000 instead of the expected G1000). As these spaces are usually quite difficult to

find, it is useful to perform a blanket clean-up of a column before using other text

functions on that column. To do this we use the TRIM function.

Page 16: Excel for Mac Text Functions - University of Brighton Documents/Excel...Excel for MAC Text Functions Printed Monday, 09 January 2017 Page | 3 Find and Replace to update multiple entries

University of Brighton Information Services

Page | 16 Last Updated 15th July 2015

The technique for the TRIM functions is the same as for other text functions such as

PROPER:

Insert a new column

In the new column, use the TRIM function to convert the text from another

column

Use Paste Values to strip the text function from the new column, leaving just

the text itself. If you already have functions dependent on the original column,

you may need to copy the new column but paste it over the original column to

avoid errors with dependent cells – see the technique used in the exercise

below.

Delete the extra column if needed

The format of the function is: =TRIM(text) where text is a cell reference.

In cell C2 in the example above, the formula would be =TRIM(B2). Let’s practise

that.

Exercise M Using the TRIM function

Continue with the exercise file LEFT_RIGHT_MID.xlsx

Insert a new column to the right of column B.

In cell C2, start your TRIM function by typing =TRIM( and then click on cell

B2. Your function should now read =TRIM(B2

Press ENTER on your keyboard to complete the function and then copy the

formula down the column using autofill.

Select column C by clicking on the column header.

Copy the selected column

Select column B by clicking on the column header.

Paste the values of the copied cells:

Click on the drop-down arrow on the Paste icon on the Home tab on

the ribbon.

In the submenu locate the option called Paste Values

Delete column C.

Page 17: Excel for Mac Text Functions - University of Brighton Documents/Excel...Excel for MAC Text Functions Printed Monday, 09 January 2017 Page | 3 Find and Replace to update multiple entries

Excel for MAC Text Functions

Printed Monday, 09 January 2017 Page | 17

Duplicate entries

There are a number of ways of handling duplicate entries in your data. We’ll look at

just some here.

Conditional formatting – this will colour duplicate entries within a column. The

technique shown here can only be used to find duplicates within one column

and not to find duplicates by comparing multiple columns in rows.

Remove duplicates – this finds duplicates and deletes them. Only to be used

when you are confident that you are happy to delete duplicates without

checking them first.

Use a formula to identify duplicates – This allows you identify duplicates by

checking multiple columns. Useful if you want to check duplicates before

deleting them.

Each of these options is explained below.

Conditional formatting to identify duplicates

This will colour duplicate entries within a column. The technique shown here can

only be used to find duplicates within one column and not to find duplicates by

comparing multiple columns in rows.

Click on the column you want to analyse

On the Home tab, click on the Conditional

Formatting icon

Click on Highlight Cell Rules

Click on Duplicate Values

A pop-up window appears. Choose how you want to

format the duplicates and click OK.

Exercise N Using conditional formatting to identify duplicates

Open the exercise file Duplicates.xlsx

On the Conditional Formatting tab, select column A by clicking on the column

header.

Page 18: Excel for Mac Text Functions - University of Brighton Documents/Excel...Excel for MAC Text Functions Printed Monday, 09 January 2017 Page | 3 Find and Replace to update multiple entries

University of Brighton Information Services

Page | 18 Last Updated 15th July 2015

On the Home tab, click on the Conditional Formatting icon

and then click on Highlight Cell Rules.

Click on Duplicate Values.

Choose to format duplicate entries with Red Text and then click

OK. All duplicate entries in column A will be coloured red.

Remove Duplicates

This is the fastest way of eliminating duplicates from your data. You tell Excel how

to identify the duplicates and it finds them and deletes them for you.

The deletion happens immediately. There is no option to check the duplicates. If

you want to check the duplicates first, do not use this option.

To remove duplicates:

Select the columns to use for

checking for duplicate entries.

On the Data tab, click on Remove

Duplicates

The pop up window confirms which columns will be

used for checking for duplicate entries, along with

how many duplicates have been found.

Click Remove Duplicates.

Exercise O Using Remove Duplicates

Continue with the exercise file Duplicates.xlsx. Click on the Remove

Duplicates worksheet. Take a look at the data and see which rows are similar

to others.

First let’s see what happens if we only duplicate rows with a match in every column.

Select columns A to D and then click on Remove Duplicates on the Data tab.

In the pop up window, leave all of the columns selected and click Remove

Duplicates.

Page 19: Excel for Mac Text Functions - University of Brighton Documents/Excel...Excel for MAC Text Functions Printed Monday, 09 January 2017 Page | 3 Find and Replace to update multiple entries

Excel for MAC Text Functions

Printed Monday, 09 January 2017 Page | 19

Excel will find no duplicates. This is because it is checking every column for

duplicates and column D has unique values.

Now let’s change the criteria to exclude column D from the check.

Select columns A to C and then click on Remove Duplicates on the Data tab.

In the pop up window, leave all of the columns selected and click Remove

Duplicates.

Excel will remove 2 duplicate rows – compare your results with the original list

shown above (or on the Conditional Formatting worksheet) to see what has

been deleted.

Use a formula to identify duplicate entries

This technique involves using a formula to make an entry in a separate column to

indicate if a row is a duplicate. You can then sort the spreadsheet and check the

duplicate rows to decide what to do with them.

In the example on the left we

have determined a duplicate

to be those rows where

columns A, B and C match

columns A, B and C in

another row.

This technique uses the COUNTIFS function, which counts cells that meet certain

criteria.

Format Example

=COUNTIFS(range of cells for criteria check 1,

criteria 1 to satisfy, range of cells for criteria

check 2, criteria 2 to satisfy,...)

=COUNTIFS(A1:A10,”Gold”,B1:B10,”>20”)

Counts number of rows where column A

contains the word Gold AND column B is greater

than 20

To use COUNTIFS to find duplicates, the format of the function is:

=COUNTIFS(A:A,An,B:B,Bn,...) where:

n is the current row number

A, B etc. are the columns to check for a match So, in our example above, the function in cell E2 would read:

=COUNTIFS(A:A,A2,B:B,B2,C:C,C2)

i.e. How many times does the content of A2 appear anywhere else in column A

(A:A) at the same time as the content of B2 appears somewhere else in column B

(B:B) and the content of C2 appears somewhere else above in column C (B:B)?

Page 20: Excel for Mac Text Functions - University of Brighton Documents/Excel...Excel for MAC Text Functions Printed Monday, 09 January 2017 Page | 3 Find and Replace to update multiple entries

University of Brighton Information Services

Page | 20 Last Updated 15th July 2015

Any result greater than 1 indicates that a duplicate has been found for that

row.

The count will always be at least 1 as the cell being checked for (e.g. A2) always

appears once in the column (e.g. column A).

Exercise P Using COUNTIFS to identify duplicate rows

Let’s practise using our spreadsheet.

Open the exercise file Duplicates.xlsx. Click on the Unique Entries Formula

worksheet.

We are going to check for rows that have the same Payroll number and Name. We

will use column E for this.

Click on cell E2 and type =COUNTIFS( to start the function

In this row (row 2) we are going to check:

If cell A2 matches any cells in column A

If cell B2 matches any cells in column B

Click on the letter A at the top of column A to select that column. This asks

Excel to check column A. The function in cell E2 will read: =COUNTIFS(A:A

Type a comma to indicate that you have finished this piece of information.

Click on cell A2. This asks Excel to look for a match for the contents of cell A2.

The function in cell E2 will read: =COUNTIFS(A:A,A2

Type a comma to indicate that you have finished this piece of information.

Repeat steps 3-5 for column B to ask Excel to check if the contents of cell B2

appear anywhere else in column B (you do not need a comma at the end of the

function). The function in cell E2 will read: =COUNTIFS(A:A,A2,B:B,B2

Press ENTER to complete the condition. The function in cell E2 will be

=COUNTIFS(A:A,A2,B:B,B2) The result will be 3. This row appears 3 times.

Copy the formula down column E using autofill.

Take a look at the results in column E. Based on our criteria (a match in both

columns A and B) only 2 rows are unique. These are identified with a 1 in

column E.

You can include as many columns as you need in your check. Let’s add column C

to our check.

Double click on cell E2 to edit the formula.

Page 21: Excel for Mac Text Functions - University of Brighton Documents/Excel...Excel for MAC Text Functions Printed Monday, 09 January 2017 Page | 3 Find and Replace to update multiple entries

Excel for MAC Text Functions

Printed Monday, 09 January 2017 Page | 21

Click just after the B2 reference so that your insertion point is flashing in

between the 2 and the final bracket.

Type a comma to indicate that you are going to add another condition to the

function.

Follow steps 3-5 for column C to ask Excel to check if the contents of cell C2

appear anywhere else in column C. The function in cell E2 will be read

=COUNTIFS(A:A,A2,B:B,B2,C:C:C2)

Press ENTER to complete the condition and copy the formula down column E

using autofill.

If you would prefer your duplicates to be identified using text rather than numbers:

Add >1 to the end of your function. So in cell E2 in the exercice above, the

function would read =COUNTIFS(A:A,A2,B:B,B2,C:C:C2)>1

Copy the function down the cells using Autofill. The example below shows how this would appear in the spreadsheet:

Where the count is greater than 1 (duplicates), the result of the function will be

TRUE.

Where the count = 1 (no duplicate), the result of the function will be FALSE.

Note: A green triangle may appear in the cells in column E when using this

formula. This is because the formula checks all cells in the column. As some of the

cells are empty, Excel gives you a warning to tell you that you have referenced

empty cells in your formula. This is not a problem here and you can ignore this in

this instance.

If you see a green triangle in a cell in Excel you should always check it by:

Clicking once in the cell showing the green triangle

Clicking on the icon that appears to the left.

Page 22: Excel for Mac Text Functions - University of Brighton Documents/Excel...Excel for MAC Text Functions Printed Monday, 09 January 2017 Page | 3 Find and Replace to update multiple entries

University of Brighton Information Services

Page | 22 Last Updated 15th July 2015

Copy & Transpose a column to a row

You can turn a column of text into a row of text and vice-versa. You do this by

copying the text and choosing Transpose instead of Paste to paste the text.

This is not used often, but it can really save you time when you need it.

Select the text you want to move

Click on the Copy icon on the Home tab on

the ribbon.

Click on the drop-down arrow on the Paste

icon on the Home tab on the ribbon

In the drop-down menu select Paste Special…

In the Paste Special menu tick the option

marked Transpose. Then click the OK button

Exercise Q Using Copy & Transpose

Let’s practise that technique.

Open the exercise file Paste_Transpose.xlsx and select cells A2 to A13.

Copy the selected cells

Click in cell B1

Click on the drop-down arrow on the Paste icon on the Home tab on the

ribbon.

In the drop down menu select Paste Special…

In the Paste Special menu, tick the option marked Transpose.

COPY &

TRANSPOSE