You are on page 1of 27

MICROSOFT EXCEL -

BULLETPROOF SPREADSHEETS

Planning and Controlling your Workbooks to


Guarantee their Accuracy

KNACK TRAINING
CONTENTS
WORKING WITH TABLES

INSERTING A TABLE 3
DYNAMIC NAMED RANGES 4

NUMBER FORMATTING

STANDARD NUMBER FORMATTING 5


CUSTOM DATE FORMATS 7
CUSTOM NUMBER FORMATS 9

CONDITIONAL FORMATTING

STANDARD CONDITIONAL FORMATTING 11


FUNCTION-BASED FORMATTING 12

LOGICAL FUNCTIONS

ERROR HANDLING 14
FORMULA DETECTION 16

DATA VALIDATION

DATA TYPES 18
DROP-DOWNS 20

PERMISSIONS

PASSWORD PERMISSIONS 21
LOCKED AND UNLOCKED CELLS 22

MACROS 23

SETUP MACRO 27

2 | Table of Contents
WORKING WITH TABLES
INSERTING A TABLE
Select a cell within a set of contiguous data. As long as the data has no empty rows or columns in it, Excel
will accurately select the rest of the region when you convert the data set into an Excel Table:

On the Insert Tab, select Table (or use the keyboard shortcut [CTRL] + [T]).

Finally, make sure the set of data is correctly selected, and Excel identified your top row as being the
header for the data (this should happen automatically if the top row has different formatting from the
remainder of the data). Click OK.

Office Tips & Tricks | 3


DYNAMIC NAMED RANGES
The most valuable feature of an Excel Table is the dynamic named range you get from it. Clicking on a
Table, look at the Design Tab, to the Table Name (the first entry on the far left):

Notice that your first Table is called Table1 (it will progress from there). By clicking in this textbox, you
can name the Table anything you like (it must (1) be unique in the spreadsheet; (2) have no spaces; and (3)
start with a letter). My preferred naming convention is:

tblPropertyTracking

In other words, the letters tbl to designate that we’re talking about a Table, then any name I like. The
name uses capital letters at each new word, since I can’t use spaces.

So, type the name you like into the Table Name box, and press [ENTER].

Now, if you create a function that references one of the columns, notice the reference is in the structure:

tblPropertyTracking[PROPERTY VALUE]

In other words, the name of the table, then the name of the column in square brackets.

4 | Office Tips & Tricks


NUMBER FORMATTING
STANDARD NUMBER FORMATTING
Number formatting is the tool Excel uses to display 3.4223 as either $3.42 or 342% or any other
equivalent representation. It doesn’t change the actual contents of the cell - just the display. Properly
formatting your cells ahead of time makes your users more likely to do simple and accurate data entry.

For most of the applicable formatting choices, click the Number drop-down menu on the Home Tab:

As you can see, there is both Currency and Accounting format with a dollar sign - this has to do with
the alignment of the dollar sign. Experiment with both, and see what you can do with these options.

Office Tips & Tricks | 5


Additionally, you can click the option for More Number Formats... at the bottom of this menu. This is
the dialog that comes up - full of customizations:

A very common choice from this dialog is the Special entry on the left panel, and choosing Zip Code.
This guarantees your Zip Codes will always display as five digits, even if there are leading zeros.

6 | Office Tips & Tricks


CUSTOM DATE FORMATS
Dates are important to get right in Excel - if Excel doesn’t recognize something as a date, it’s entered as
plain text. This means you can no longer sort or filter by the date, nor do calculations with those dates.
The problem is that many people are looking for a creative representation of your date. Lucky for us - it’s
easy to make your date anything you want. Start by clicking Home Tab > Number Drop-Down > More
Number Formats...

Now, you can begin by choosing the Date entry on the left panel, and looking at the default formatting
choices. Pick one that at least gets you close to what you want.

Office Tips & Tricks | 7


If that’s not perfect, now switch to the entry Custom on the left panel. Notice that your date formatting
has been changed into a representation in d, m, and y (days, months, and years, if that needed saying).

Simply type 1, 2, 3, or 4 characters of d, m, or y, and see how Excel begins representing your date:

A single character (m or d) represents one-digit dates (like January or the 8th) as one-digit values (1
or 8), but it represents two-digit dates (like November or the 22nd) as two-digit values (11 or 22). Two
characters represents all date values as two digits - you’ll see values like 02, 07, 12, or 30.

Three characters uses a three-character abbreviation of your entry - Jan or Mon - and four characters
writes out the value completely.

Years, since they should only be represented by two or four digits, are only allowed to use two or four (98
or 1998, but not 998).

8 | Office Tips & Tricks


CUSTOM NUMBER FORMATS
Most of the time, a simple whole number, decimal, or dollar value is exactly what you need in a
spreadsheet. However, for data visualization purposes, it can be valuable to simplify the value you show.
For example, $72,422,121.04 could be represented as $72.4 M to make it easy to process. Unfortunately,
most people will hand-type the information, removing the possibility for calculations to update it, or for it
to be used in other calculations.

Office Tips & Tricks | 9


Once again, you’ll need to start by clicking Home Tab > Number Drop-Down > More Number
Formats... You’ll see the standard number formatting choices, but when you click over to the Custom
entry, you’ll notice that number formats (as opposed to date formats) use the characters 0 and #. Zero
represents a position that must be shown (like a dollar value that’s shown as $5.00 - you don’t need the
zeros, but you decide to show them for clarity and accuracy), while the pound sign represents positions
that will be shown if they exist (#,##0 shows both 5 and 12,333, for example - it shows the tens,
hundreds, thousands, and ten thousands positions, and the comma, if they’re needed, but when they’re
not needed they’re left off).

Try the following codes:

$ 0.0, “K”

0.0,, “million”

In the first, 67,161 will be shown as $ 67.2 K, and in the second 4,222,000 is shown as 4.2 million. You
can see that in both, there are commas without any numbers between or after them. This represents the
digits you aren’t showing.

10 | Office Tips & Tricks


CONDITIONAL FORMATTING
STANDARD CONDITIONAL FORMATTING
Conditional Formatting is changing the visual of a cell - font, color, borders - based on conditions. Some
of the most common conditions are numbers in a range, biggest values, or duplicate values. Very
often, you’ll apply conditional formatting to many cells at the same time, so you can pick out the few cells
that match what you’re looking for. One example is highlighting the biggest value:

Select a range of cells, like H4:H15:

Then, click Home Tab > Conditional Formatting > Top/Bottom Rules > Top 10 Items...

Finally, set the number of items to highlight to 1, and choose an appropriate formatting:

Office Tips & Tricks | 11


FUNCTION-BASED FORMATTING
Standard conditional formatting works well when you want to change the color of a cell based on the
value of that cell, but sometimes you want to base it on the value of other cells, or based on some other
characteristic than its value. In those situations, you’ll need to create a custom conditional formatting
based on a calculation you create. In this example, we want to color-code cells that have been hard-
coded, rather than calculated (this happens too often when people just want a number in a cell, and
don’t know how to create a calculation for it). Luckily, Excel has a function called ISFORMULA that
checks whether a cell is being calculated.

First, select the cells that should be calculated:

12 | Office Tips & Tricks


Now, select Home Tab > Conditional Formatting Drop-Down > New Rule...

Choose the entry for Use a formula to determine which cells to format. In this cell, we want to
color-code a cell if the cell is not a formula - so the function looks like this:

Note that our reference has no dollar signs on it - this is because we want to apply the same functionality
to each cell we have selected.

Office Tips & Tricks | 13


LOGICAL FUNCTIONS
ERROR HANDLING
Very often, you’ll need to use functions that have well-established error conditions you can predict. Here
are two examples:

The AVERAGE function takes the average of the values in a set of cells. However, if there are no values in
those cells, the function attempts to divide by the zero values - which is a bad thing in math. So, when
you set up a spreadsheet to average values before they’ve been entered, the function will default to its
error condition.

The VLOOKUP function looks for a matching value to an ID number or other value. If there’s no match,
it returns the value #N/A, which looks bad to uninformed users of the spreadsheet. When it looks bad,
someone may take it upon themselves to ‘clean it up,’ breaking your spreadsheet.

To handle these situations, there are logical functions - functions that ask true/false questions - for
IFERROR and IFNA. You can nest the functions you’re creating into these, and output better values when
these situations arise. Our first example:

We’ve created a table with properties and their values.

Now, let’s assume there is a situation where this table starts empty:

The average of the PROPERTY VALUE column is done, and comes back with a poor result:

14 | Office Tips & Tricks


The solution is to nest the AVERAGE function into the IFERROR function, providing a value in the event it
would error (in this case, I like 0).

Office Tips & Tricks | 15


FORMULA DETECTION
Logical functions can be used to good effect in both Conditional Formatting and Data Validation. For the
Conditional Formatting example of this, check page 12. In this example, we’ll use ISFORMULA to force
our users to keep lookup functions in place.

We begin by creating a Table out of our data - we do this because a Table automatically copies the
formatting and validation rules to each new row of the data, as the information changes:

Now, in one or more of the columns, calculate a value, instead of having it be raw data entry. In this
example, we use VLOOKUP to find the Customer and Point of Contact from the Customer ID:

This works great - and we’d hate for our users to type their own Customer Name and Point of Contact. So,
click on the cells that have the calculation:

Click Data Tab > Data Validation:

16 | Office Tips & Tricks


Choose Custom.

Now, you’re going to create a formula that asks whether the value in the cell is still a formula:

Office Tips & Tricks | 17


DATA VALIDATION
DATA TYPES
If you’re building a big visualization or analysis of a set of data, nothing is more frustrating then having
pieces of data that don’t work correctly because of how they were entered. For example, if someone
enters the date January 1, 2018 as 01.01.18, Excel isn’t going to read that as a date. When that happens,
you have a data point that doesn’t get calculated in January, and you might make a big mistake that costs
the business money. Instead, we can use Data Validation to require what is entered matches our needs.

A very common example of Data Validation is requiring values to be dates or numbers, and stopping the
entry of values that don’t match those data types.

First, select the cell(s) that will have the data entry.

Now, click Data Tab > Data Validation.

18 | Office Tips & Tricks


Choose the data type you’re interested in - in this case, we’re looking for everything to be a Date.

Finally, choose the range that works for the situation.

To complete the validation, you can choose to give a user-friendly message on the Input Message tab:

... and put a useful Error Alert message:

Office Tips & Tricks | 19


DROP-DOWNS
When the data to be entered is directly from a list everyone already knows - like a list of our employees,
products, or customers - it’s critical that every time you enter the data, it matches the list. The only way to
do this - eliminating abbreviations and misspellings - is to reference that list and force your users to pull
directly from the list. We do this with drop-down menu validation.

First, create your list (hint: putting it in a Table lets it grow as you get more customers):

Now, select the cell(s) that will be referencing this list:

Again, if you put this is a Table, the validation will be applied to all new records. Click Data Tab > Data
Validation:

On the first drop-down, choose List:

Reference your list of entries, either by cell references or named ranges:

20 | Office Tips & Tricks


PERMISSIONS
PASSWORD PERMISSIONS
On the Review Tab, you can choose to password protect any sheet in your workbook with Protect
Sheet. Then, assign it a password. You’ll also notice that you can Protect Workbook, which protects the
file against being accessed at all.

When you password protect a sheet, as you can see, it protects the locked cells against various
functionality. You can click through the various checkboxes to choose what the user is capable of without
the password.

Then, of course, you can provide the password to users who would like to unlock the full functionality of
the spreadsheet.

Office Tips & Tricks | 21


LOCKED AND UNLOCKED CELLS
However, most people gloss over the idea of locked vs. unlocked cells. Which cells are locked, and how did
they become locked? If you select any cell(s) and press the keyboard shortcut [CTRL] + [1], you’ll notice
that there is a tab devoted to Protection, and that the cell(s) you chose are currently locked. This means
that by default, all cells have protection on them when you assign a password.

However, by unlocking certain cells, you make it possible for the user to perform their data entry tasks
in the unlocked cells without providing them the password. To see this in action, watch the video at:
https://knack.link/UnlockedCells-Video

22 | Office Tips & Tricks


MACROS
STOP: BEFORE YOU USE MACROS
[1] ENABLE THE DEVELOPER TAB
Before you record macros, assign them to buttons, or otherwise interact with the coding side of Excel,
turn on the Developer Tab. Click File Tab > Options > Customize the Ribbon.

Turn on the checkbox labeled Developer.

Office Tips & Tricks | 23


[2] UNDERSTAND YOUR SECURITY SETTINGS
Most users will want Medium security in Excel, which disables all macros but asks whether you want to
enable them. Click Developer Tab > Macro Security to choose the appropriate setting for your comfort
levels.

By placing files that use macros into a Trusted Location, those macros will always be automatically
executed. Click File Tab > Options > Trust Center > Trusted Locations to create folders that are
automatically trusted to run macros.

24 | Office Tips & Tricks


[3] WHERE ARE YOU PUTTING THE MACRO?
Your first option is to create a simple spreadsheet that contains the macro. The file type should be .xlsm
for an Excel Macro-Enabled Spreadsheet. The macros contained in this file only affect the current file.

Your second option is to create a template that contains the macro. The file type would be .xltm, for an
Excel Macro-Enabled Template. The macros contained in this file affect all future files created from the
template.

Your third option is to save your macro to your Personal Macro Workbook, named Personal.xlsb.
This is the file location for macros to affect every spreadsheet you open.

Office Tips & Tricks | 25


To access your Personal Macro Workbook, click View Tab > Unhide, and choose PERSONAL.

[4] WHAT IS YOUR COMPANY’S POSITION ON MACROS?


In order for a macro to run, the spreadsheet must have enabled macros, which can be dangerous. Having
a Trusted Location where macros always run can also be dangerous. You need to confirm your company’s
stance on enabling macros internally.

Additionally, you need to ask yourself if this macro should be propagated throughout the company. If so,
how should you name the macro and the elements within the macro? What would be clearest for someone
else trying to figure out what your macro does? What comments are going to be valuable to others who
use it?

[5] RECORDING VS. WRITING


Finally, the question is: can I record this macro, or must I code it? Recorded macros are direct - they inform
Excel what to click on, and in what sequence. However, recorded macros don’t contain information about
decision-making, error handling, or repeating a step as many times as necessary. For those more advanced
concepts, coding is required.

26 | Office Tips & Tricks


SETUP MACRO
Once you’ve covered these bases, you can implement any macro - here’s a recommended one for making
your spreadsheet bulletproof:

You can use the unlocked cell property with password protection to create specific data entry cells. In
addition, putting a color in to identify the cells will focus their attention. Click the Developer Tab and
choose Visual Basic.

Now, choose your VBAProject (Personal.xlsb), and click Insert Menu > Module.

Finally, copy-and-paste our macro into this Module:

You can now use the setup macro to highlight cells, unlock them, and change their color.

Office Tips & Tricks | 27