Académique Documents
Professionnel Documents
Culture Documents
BULLETPROOF SPREADSHEETS
KNACK TRAINING
CONTENTS
WORKING WITH TABLES
INSERTING A TABLE 3
DYNAMIC NAMED RANGES 4
NUMBER FORMATTING
CONDITIONAL FORMATTING
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.
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.
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.
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.
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.
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).
$ 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.
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:
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.
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:
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:
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:
Now, you’re going to create a formula that asks whether the value in the cell is still a formula:
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.
To complete the validation, you can choose to give a user-friendly message on the Input Message tab:
First, create your list (hint: putting it in a Table lets it grow as you get more customers):
Again, if you put this is a Table, the validation will be applied to all new records. Click Data Tab > Data
Validation:
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.
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
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.
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.
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?
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.
You can now use the setup macro to highlight cells, unlock them, and change their color.