Advanced Excel Smart Book PDF
Advanced Excel Smart Book PDF
in
This book is divided into 9 parts that talk about various advanced
concepts and explain how to integrate them with one another
I have tried to write this book like a dialogue to make it fun filled and
humorous while the technical alchemy is at play. The topics are placed
in logical order and often draw learnings from each other, alongside
you must also refer to the spreadsheets that come along
2. Array Formulas 36
3. Excel Tables 43
4. Advanced Filter 49
6. Form Controls 59
7. Pivot Tables 69
9. Sheet Protection 91
1. Advanced Excel
Formulas – Lookup
Functions
4
Index
The INDEX function is the big daddy of the VLOOKUP function, How? Because
of its powerful utility and faster processing. Let’s go check out this beast and
mature our understanding step by step
Syntax
INDEX(array, row_num, [column_num])
The Index function returns the intersection of the row and column number
Case
Lets say we want to find the record Ashley for the Month of Feb, which you
can easily do it with a VLOOKUP formula but here is how the INDEX would do
it
Column Number
James’s record is in
row 4 and col 3
Row
Number
Now apart from simply being an alternative to VLOOKUP and returning the row
and the column number
Tricky Question? What if you wanted to do a total for James sales and not
just return the sales of Feb ? Here the VLOOKUP would fail!
Now when you press enter the formula will give you ‘James’ as an output. The
reason is that no excel formula is capable of giving multiple values as an
output. But writing 0 in the column number fetches all the values in the row.
Now all you need to do is wrap the INDEX around the SUM function
Syntax
MATCH(lookup_value, lookup_array, [match_type])
YOU
Now lets make a big deal out of this no big deal MATCH function ..
Ready?? Ok lets go ahead and solve 2 problems
© Goodly www.goodly.co.in 6
Index and Match together
Put both of them together an you have Superman ready !
Now the same example and we are trying to find the position of James
1 3
Self Work
© Goodly www.goodly.co.in 7
Lookup to the Left
Lets put our superman to work for looking up to the left of the data range
• EMPID0011
• EMPID0012
Lets first write a MATCH formula to find the position number of those 2
employee IDs. Note that I have frozen the lookup range
© Goodly www.goodly.co.in 8
Index – Advanced *
Now think of INDEX like your intelligent secretary who is better
than VLOOKUP. What I mean to say is that this secretary of yours Hi, my name is
(INDEX) has the capability of looking up at different data sets. So INDEX
if INDEX wont find the lookup value in one data range it will go
and find it another range
Syntax
INDEX(reference, row_num, [column_num], [area_num])
Two things change here (reference and area number, so I’ll cover those 2 and
rest remains the same
Reference – is the range of the multiple data sets
Area_num – is the number of the range where you want to search
* The index function has two syntaxes, for simplicity reasons we are denoting it as Index Advanced. You
see both the syntaxes when you type =INDEX(
© Goodly www.goodly.co.in 9
Index - Advanced
2. We enter our usual row and the column input.
© Goodly www.goodly.co.in 10
Choose
I think life becomes great when we have the options to choose from. To make
your formulas more versatile excel gives you a CHOOSE function. Lets take a
look
Syntax
CHOOSE(index_num, value1, [value2], ...)
Self Work
Let’s play with the capabilities that we have acquired till now. Being INDEX
MATCH and CHOOSE in your arsenal your secretary has now become a super
woman.
Same case but a different question, you have to find the salary of ‘Greeko’ but
you don’t know in which table has his record and you neither know his row
number
Hints
© Goodly www.goodly.co.in 11
Indirect
Let’s say we are making a journey, but we don’t know where are we going? ..
I know it kind of sounds bizarre but I said that WE don’t know about our
journey someone else knows, so we have to go to that someone and find out
where we are going. I know I know it sounds like a big BS but hang in there
Hi
A100 Cell A100, has the text
This is our Indirect
Hi
function, going to This is ‘someone’ (Cell
‘someone’ which is INDIRECT will return
A1) and it is asking us
cell address A1 value in A100 i.e. Hi
to go to Cell A100
I know INDIRECT gives you a kind of feeling that where the hell am I going to
use it ? But I will settle your woes in a while, as of now lets cover the syntax
in a bit more structured way
Syntax
INDIRECT(ref_text, [a1])
Ref_Text – This is your cell address which leads you to another cell address
A1 – This is the way how Indirect will read the cell address. Let’s just stick to
choosing TRUE as an option for now. This is an optional input & gives the
TRUE value by default
Take a look
© Goodly www.goodly.co.in 12
Offset
Pure Monster! It has absolute killer utility but should be used with caution
because of its volatile nature, we’ll discuss a bit on volatility later but as of
now lets ride on OFFSET for a while
Syntax
Reference – This is your starting point in the sheet. Typically a cell address
Rows – No of rows you want to travel downwards/upwards from the start point
Cols – No of columns you want offset to travel left/right from the start point
We’ll discuss height and width (which are optional) in a while as of now let’s
take a stock of what we got here!
© Goodly www.goodly.co.in 13
Offset Advanced
Just for simplicity reasons lets call this as Offset Advanced. Let’s look at our
case where I want to add the range of data (100,800,300,200)
Now we specify
• Height as -2 (our range of cells is 2 rows
upwards in height)
• Width as 2 (range of cells is 2 columns in
width)
• Don’t press enter!!
Width
Height
OFFSET holds the array of cells in its mind and is not capable of displaying
them in one single cell, secondly we have not specified anywhere that we want
to take a sum of those value… OFFSET is so dumb!! I know .. but we’ll have to
wrap OFFSET around a SUM function
Now the possibilities are limitless of how can you use this. I’ll discuss some of
its advanced features a bit later.
Please note that
o Positive Row Numbers or Height – Travel Down that many rows
o Negative Row Numbers or Height – Travel Up that many rows
o Positive Column Numbers or Width – Travel Right that many columns
o Negative Column Numbers or Width – Travel Left that many columns
© Goodly www.goodly.co.in 14
Columns and Rows
They say simple things always make a killing utility, the saying goes true for
COLUMNS and ROWS functions as well
Syntax
=COLUMNS(array) =ROWS(array)
Array – select a range of cells and it will specify how many columns or rows
are there in that range
Lets make a killing by combining the VLOOKUP and the COLUMNS function
1
© Goodly www.goodly.co.in 15
Address
The simplest way to describe this function is that it returns the cell address of
any cell. Let’s take a look
Syntax
ADDRESS(row_num, column_num, [abs_num], [a1], [sheet_text])
Lets say we are using the ADDRESS function on the cell A5 (outlined in
picture)
1 denotes the A1
style referencing.
When you press enter you’ll get the cell address $A$5. We’ll stick to A1 style
Now seriously, there is no big deal about this. Let’s get referencing to most
into a case where use the INDIRECT function with the part of our learning
ADDRESS Function
© Goodly www.goodly.co.in 16
Indirect Function Application
Lets take a look at an interesting case. I have 3 sheets and some data on each
of them
© Goodly www.goodly.co.in 17
Using Wildcards in Formulas
Just like the Joker in playing cards (which can fit anywhere) we have
wildcards in excel that do a similar job. Now these wild cards can be
combined with excel functions like AVERAGEIF/IFS, COUNTIF/IFS,
H&VLOOKUP, MATCH, SEARCH, SUMIF/IFS, etc..
Lets get going with an example. In the example below we have to total the
CTC for all employees whose EMP codes are in 11 series (i.e. starting from
11). Now if this data would have been a couple of thousand rows, it would
truly have been a nightmare without the wildcard feature
This will find all the records which have 11 in the EMPID
How the * Asterisk works: If the asterisk symbol is applied before a text
string, it would match everything that ends with that text string. For example
SUMIF(Range,”*ber”,Sum_Range) will include the sales for the last 4 months
because they end with the string ber (September, October, November,
December)
How the ? Question mark works : Unlike the asterisk, a question mark
matches any single character For example, =COUNTIF(range, “sm?th”) will
count all the smiths either with an I or Y (smith / smyth)
© Goodly www.goodly.co.in 18
1. Advanced Excel
Formulas – Date &
Time Functions
19
A quick recap - how date & time works in Excel
There is a special way how excel treats dates. For Excel, dates are nothing but
numbers. To give you more insight, each date is a sequential number to excel
for example my birthday 27-Apr-1986 is numbered as 31529. Now the obvious
question is that, where did this number come from?
Let’s unravel this, The excel calendar begins on 1st Jan 1900 so that it is
stored as the number 1 in Excel’s memory, 2nd Jan 1900 is stored as the
number 2. Programmers have stretched the calendar till 31st-Dec-9999 (I am
not sure if we are going to go that far in any sort of calculations, at-least I
have not!)
DATES ARE NUMBERS IN EXCEL
1-Jan-1900 31-Dec-9999
Starting date Last date
1 2 3 4 5………………………………………………………………………………………………………..2958465
A quick exercise - Can you find out the number of your birthdate ?
Just like dates, time is also a number but time being a smaller fraction (as
compared to dates) they are presented as decimals. Let’s continue with my
birthday, so the number is 31529
© Goodly www.goodly.co.in 20
Day, Month, Year
Now that you have an understanding that dates are nothing but numbers in
excel. Lets take a look at 3 foundation building functions (DAY, MONTH, YEAR)
Simply put the DAY function will return the DAY of the month, for example if
the date is 14 Feb 2014, DAY will return the number 14 (as the 14th day of
the month)
Make no mistake in understanding, The
DAY function is extracting the day of
the month from a serial number(which
is appearing to you as a date)
The MONTH function will return the Month of the Year, for example if the date
is 14 Feb 2014, MONTH will return the 2 (as 2nd month of the year)
The YEAR function will return the Year, for example if the date is 14 Feb 2014,
YEAR will return the 2014 (as the year number)
© Goodly www.goodly.co.in 21
Date
The date function in excel can combine the (DAY, MONTH AND YEAR) function
and return the date. The previous 3 functions can disassemble a date and the
DATE function can reassemble a date
Syntax
DATE(year, month, day) – They are pretty explanatory, so I’ll directly jump
into an example
In our earlier example we used the DAY, MONTH and YEAR function. I am now
adding a fourth column to combine the 3 separated elements (day, month,
year) by the DATE function
© Goodly www.goodly.co.in 22
Second, Minute, Hour
Here we break down the date into even smaller elements (Second, Minute and
Hour). Lets take a look
© Goodly www.goodly.co.in 23
Time
Just like the DATE function, the TIME function combines the 3 elements of
time (Hour, minutes and seconds)
Syntax
TIME(hour, minute, second)
Here the TIME function is combining the smaller elements and giving the time
Ok let’s look at a similar function which combines the TIME and the Date
together
Now
=NOW() returns the present date with time
© Goodly www.goodly.co.in 24
Weekday and Weeknumber Functions
Excel has some built in functions that help you do different date related
analysis like counting the day of the week or counting the week of the year,
lets check out these
Weekday function returns numbers 1 to 7 denoting the day of the week. Let’s
say I want to know which day of the week was 3rd May 1988. In the example
below I select the date and choose the week starting number. Take a look at
the drop down that pops up when I am inputting the return type. It gives you
a lot of flexibility to choose when is your week is starting
This function returns the week number of the year. Continuing with 3rd May
1988, the week number of this date is 19 (if we start the week on Monday)
© Goodly www.goodly.co.in 25
Time Stamp Problem
Now with some of functions under our belt let’s solve a typical problem at
work. Lets say we need a time stamp against every data entered but the
condition is that once the time is stamped against the data it cannot be
changed. We would use a simple IF formula for this but with a new concept
called Circular Referencing
Each time we run the formula (pressing F9) the value in A10 will goes up by 1.
Turning ON Iterative calculations - Office Button > Excel Options > Formulas >
Check
© Goodly www.goodly.co.in 26
1. Advanced Excel
Formulas – Math
Functions
27
Ceiling and Floor Functions
I think these 2 functions are incredibly simple and powerful
I think I’ll make more sense with this example. Consider a set of numbers, In
the formula I have specified the number and the significance as 3. Now this
function will take the numbers and push them up to the next multiple of 3. For
example if =CEILING(11,3) will result in 12, because the next multiple of 3
after 11 is 12
For Example
=CEILING(14,3) will
result in 15
If you have understood the CEILING function the FLOOR function is just a
sitter for you. Just as the CEILING function pushes any number to the next
multiple of the significance, the floor function pushes the number downwards,
here is the syntax
© Goodly www.goodly.co.in 28
Even and Odd
A little less sophisticated are the cousins of CEILING & FLOOR i.e. EVEN and
ODD functions
Just as the name suggests, the EVEN function returns the next even number
to the number specified in the function
Right opposite to that is ODD which returns the next odd number to the
number specified in the function
© Goodly www.goodly.co.in 29
Finding out Quarters of Dates
Self work Exercise
Finding Indian Quarters - See if you can tweak the formula a bit to find out
Quarters for Indian financial year? That means that quarter 1 is from Apr -
June
© Goodly www.goodly.co.in 30
1. Advanced Excel
Formulas – Information
& Text Functions
31
Cell and Info Functions
These come handy when you want to know some information about a cell.
Take a look the syntax
Syntax
=CELL(info_type, [reference])
Info_Type – It gives you a list of information that you can pick up from
Reference – Cell address for which you the information selected. This is
optional if not specified the formula gives the information about the cell in
which the formula is typed
The INFO Function is similar to cell function. Just type =INFO and select the
information that you need
© Goodly www.goodly.co.in 32
Ifna
IFNA function is similar to IFERROR function. The only difference is that it only
checks for #N/A error
Syntax
IFNA(value, value_if_na)
In the case mentioned below IFNA will return N/A since the VLOOKUP range is
empty, in that case the formula will return the text OK
© Goodly www.goodly.co.in 33
Clean and Trim
These two function come very handy when you have to clean your data. Lets
take a dive
The clean function is used for removing all non printable characters from the
next. Take a look at this case where each last name is appearing the next line.
I have to remove all the ‘enters’ before the last name for which I can use the
clean function
The trim function removes all spaces from text except for a single space
between words. You can use TRIM on text that you have received from
another application that may have irregular spacing
© Goodly www.goodly.co.in 34
Rept
At the first glance this function will look like, am I really going to use this? But
I’ll tell you one of the coolest trick with function. Let’s do this
Syntax
=REPT(text,num_times)
For example if you write =REPT(“a”,10) it will repeat ‘a’ ten times and return
aaaaaaaaaa, now as promised let me show you something cool about this
function. Lets say we have a set of sales numbers for which we want to make
a chart
How would you make a chart using the REPT function when the sales values are
large, consider this example ?
© Goodly www.goodly.co.in 35
2. Array Formulas
They are also know as CSE (CTRL+SHIFT+ENTER) formulas because of their
conditional capability of only working by pressing Ctrl + Shift + Enter. This is
one of the difficult topics in Excel so to make this topic fun and interesting
we’ll take a look at various concepts in various examples discussed in this
section
36
Array Formulas
An array formula has an advanced capability of handling operations for not a
single cell but a range of cells together.. Eh?? Confused? Forget that take a
look a case here
Question : You have to find the total change (close price – open price) by
writing one formula in a single cell?
1. Inside the SUM function I have selected the Close Price Range and Open
Price Range
2. The way it will work is, the formula will take the difference between each
values in the 2 ranges and then sum it up
3. But I cannot run this formula by pressing ENTER, it will give me a #VALUE
error, I have to use CTRL + SHIFT + ENTER to execute this formula
© Goodly www.goodly.co.in 37
Array Formulas
Now the obvious question arises that how would you know if a formula is an
array formula?
© Goodly www.goodly.co.in 38
Array Formulas
Observations from the example
1. Do not press enter mistakenly after you have evaluated a part of the
formula by pressing F9. WHY? Because F9 is the calculation key and it
would replace the cell references with absolute values in the formula after
you press enter. So either press ESC key (to come out of formula cell edit
mode) or press CTRL Z to undo the F9 key effect
2. Just as we saw in the example the F9 key can evaluate a part of the
formula so you can technically break down the evaluation in bits and pieces
and understand a formula
3. This F9 calculation feature is insanely beneficial when you are making some
serious formula alchemy and you want to keep testing the results as you
build up a giant formula monster
Lets delve deeper and get more Geeky with Array Formulas. Let me pick up an
example an introduce a new concept (that works as a backbone) in array
formulas. We have stocks their Purchase Price and Market Price. We have to
find the total Profit made on all the stocks but keeping the power of array
formulas in mind, we got to do that with a single formula in one single cell
The Logic is that the stock would obviously be sold if the Purchase Price is
less than the Market Price, else one would not sell the stock! Sounds Right?
© Goodly www.goodly.co.in 39
Array Formulas
Evaluating the formula with the F9 key – How the Boolean Works
1. Select the first range in the IF Condition and press F9 – The first rang
expands to show the purchase prices of different stocks
2. Select the second range in the IF Condition and press F9 – You will get the
range of market prices
3. Select both the ranges in IF condition and press F9 – You will get TRUEs
and FALSEs for purchase price being compared to market price. Where ever
the condition is true it will display TRUE else FALSE
These TRUES and FALSES are Booleans. For each True IF will
pick up the difference between Market Price and Purchase
Price and for each False IF will pick up 0
4. Select the next range for Value if TRUE and you will get the difference
between the two ranges by pressing F9
5. Finally select the entire IF statement and press F9 - IF will pick Market
Price – Purchase Price for only the TRUE Values
Check out the 0 (zeros) in between the values. Those are places
where the IF condition was giving a FALSE
6. Now SUM will sum only the positive values (i.e. where you have made a
profit)
© Goodly www.goodly.co.in 40
Array Formulas
As of now we have been talking about formulas that can be forced to operate
and calculate arrays by pressing CTRL SHIFT ENTER but then there are also
exclusive array formulas that just work with CTRL SHIFT ENTER not otherwise
Frequency Function
This function can calculate the frequency distribution between different
intervals.
Syntax
=FREQUENCY(data_array, bins_array)
data_array – The data from which we want to calculate frequencies
bins_array – These are intervals
This formula would require you to first select a range of cells where you want
the result (one extra cell than the bins_array)
Syntax
=Transpose(array)
Array is the range of cells that you want to transpose. Excel automatically
converts a vertical array to horizontal and vice-versa.
© Goodly www.goodly.co.in 42
3. Excel Tables
Before we get started with this section, I want to write a prologue
about its awesomeness. I have not seen this feature to be too familiar
with the excel fraternity but this is very powerful for whole bunch of
reasons. Lets take a sneak peak into what are we going to cover in
this section
1. Excel Tables – What are they and how are they created ?
43
Excel Tables - getting started
What are Excel Tables ?
I am not going to make this boring.. So let’s take a look at some sales
transaction data
590 rows of
such data
Creating a Table ?
This data spreads from Column B to G and runs in about 600 rows. Lets
convert this data into a table
1. Select any cell inside the data range and use the shortcut Ctrl+T
2. You’ll have a ‘Create Table’ dialogue box intuitively guessing the
range of the data and asking if your data has headers
3. Go ahead and click OK. Note that headers should be present in the
data range and should be ticked (in our case)
• Formatting
has changed
• Filters
appeared
• Alternate
rows
coloured
• Thin border
outside the
table
© Goodly www.goodly.co.in 44
Excel Table – What is so special about them
Here are my top 8 reasons to use table. Lets explore them
2. Effortless data entry – As soon as you enter a new row or column Excel
picks up the new data in the table structure
© Goodly www.goodly.co.in 45
Excel Table – What is so special about them
If you are wondering, how is the formula written. Is this range naming or
something else? Let me tell you it is none of those but Structural references
Lets say you want to calculate 30% tax on profit, the way it will work in tables
is as follows. Start typing in the highlighted cell
=[Profit]*30%
As soon as you press enter excel will populate the answer in the cells in the
Tax Column. This kind of referencing is called structured referencing
1. Since there is no cell referencing (=A1) the table is referred by its structure
or the headers for example =[sales]*[commission], this will take each row
in the sales column and multiply it with each row in commission column
2. If you only type headers or column name (always in square [..] brackets),
be sure to be working in the adjacent row or column of the table. Like we
just did our tax calculation(which was an adjacent column to the table)
3. If you are referring the column header in some function or anywhere else
in the sheet (which is not adjacent to the table) then you also have to
specify the table name. Here is how you do it
=SUM(TableName[Sales]) this would total the sales column in the
table name you specify
=Sales[Profit]*Tax[TaxRate] this would take each item row of Profit
Column from the sales table and multiply it with TaxRate column in the
Tax Table
Case
For instance we have two tables
Name
Named as
Named as Sales
Cust
Our task: find the correct customer code from the customer table and put it
against each customer in the sales table. Simple VLOOKUP, here is how we
would do it!
Next Task: We have expanded the customer table and we have to find the
total of each customer sales from the sales table
© Goodly www.goodly.co.in 47
Excel Table – What is so special about them
8. Dynamic Charts and Data Ranges – now such a beauty can be extended
to charts and dynamic ranges in pivot tables as well. Consider the following
data, where we have used a table to make a chart
The same concept can be applied to pivot tables as well. Let’s say we want to
make a pivot table from Sales table
We just entered the table name in the Range field, now as and when new data
is added to the sales table the Pivot table just needs to be refreshed and new
data will be picked up in the Pivot Table automatically
© Goodly www.goodly.co.in 48
4. Advanced Filter
49
Advanced Filter in Excel
This is one of the most underrated features on the contrary it is of great utility
and easy to use !! Lets pick up a case to get a hang of this
The advanced filter is located in the DATA tab by the name ‘Advanced’
(Shortcut key – Alt A Q)
Make a separate place for writing the criteria on the sheet, let’s say on the top
of our data. Include the headers too while writing the filter criteria, with the
help of headers advanced filter will identify the which criteria will apply to
which column of the data. So this is how we do it
© Goodly www.goodly.co.in 50
Advanced Filter in Excel
Applying the Advanced Filter
1. Go to the DATA tab and click on Advanced
2. Advanced Filter dialogue box pops up with 4 inputs
o List Range –> Select the entire data including the headers
o Criteria Range –> Select the criteria range (two rows including the
headers)
o Click the Radio Button –> Copy to another location and click anywhere
else on the sheet, where you want the filtered data to be copied
o Unique Records –> If you are looking for only unique records then
check the unique records button
3. And you are done! Yes it is that simple :-D
Filter
criteria
Applying Diverse Filter Criteria - You can apply filter criteria in a diverse
ways.. lets check outs some
Filtered records for Veronica and MNTL and records for White Associates
with Sales greater than >10000
Filtered records between 2-Jan-2005 and 31-Dec-2006 for Customer MNTL and
filtered records for Boston Consultants for Sales >10000 in the Region East
© Goodly www.goodly.co.in 51
Advanced Filter in Excel
Partial Filter Result - You can also retrieve partial information, for instance I
want to apply the following filter
And the filtered records should only come for Date and Sales for that just
write the headers Date and Sales in the Copy to Location (on the sheet) Select
those headers only in the advanced filter (copy to location) option The records
will only populate the Date and Sales for Swati and East
Criteria
Filtered
records only
for Date and
Sales
© Goodly www.goodly.co.in 52
5. Advanced Cell and
Range Naming
53
Cell & Range Naming
This is very straight forward and is the foundation of what we are going to
learn about dynamic range naming and integrating multiple ranges in a
formula. Lets get done with this quickly. You have a list of employees for which
you need to calculate 20% commission on annual CTC
1. Lets name the commission % cell. Select the cell and type the name in the
Name box on top left corner. Be sure to press Enter after typing the name
2. Now write your formula to calculate commission using the cell name
Just like naming a singe cell you can name the entire range as well. Nothing
too complicated, just select the entire range and type a name in the name box
and then use them in your formula. Here is a snippet
© Goodly www.goodly.co.in 54
Cell & Range Naming
Cell Naming Rules that you need to keep in mind
• An Excel name can't contain space characters
• The first character of a name must be a letter, underscore (_) backslash (\).
Remaining characters in the name can be letters, numbers, period,
underscore characters
• Names can contain uppercase and lowercase letters, and Excel does not
distinguish between them. For example, North and NORTH are treated as
the same name.
• Names cannot be the same as a cell reference, such as A$35 or R2D2
© Goodly www.goodly.co.in 55
Formula Based Range Naming
Now that we have covered all good to know stuff, lets have the real meat. So
we have a situation where we need to automatically create a sales chart for
the most recent quarter
Note that this is not the correct place to write the formula. The formula will be
written in the Name Box
If you have gotten till here understanding most of what we have discussed
then you must be thinking that this can be done by Excel Tables (they are self
expanding when new data is added) but my friend they just expand and pick
up all the data in the table, but we need to only pick up on the most recent
quarter and not all.
© Goodly www.goodly.co.in 56
Formula Based Range Naming
Now go to the Name Manager (CTRL + F3) in formulas tab and click on the
‘New’. A New Name dialogue box will appear
Now pick up the last of data and make a simple column chart
‘mapping sheet.xlsx’!Last_row
© Goodly www.goodly.co.in 57
Formula Based Range Naming
1. Create a formula that only picks up the quarter in the last row
2. Name a cell with that formula
3. Place it in the chart!!
© Goodly www.goodly.co.in 58
6. Form Controls
59
Form Controls
Ever imagined talking to your spreadsheet report
You: Hi, Spreadsheet can you show the comparison between Co A and Co B and
take off Co C from the chart
You: Ok great, Now I want the top ten customers for Co A and Co B
The form controls feature let’s you do just that. Cool..eh? We can develop
some self explanatory buttons and tools to get answers to questions like
above and make our bosses happy… So let’s do this
Form controls are placed in the Developer Tab. If you are unable to locate the
Developer Tab you’ll probably have to turn it on
© Goodly www.goodly.co.in 60
Form Controls
Turning on Developer Tab in Excel 2007
1. Visit the ‘Excel Options’ again by clicking the Microsoft Window button on
the top left corner of the screen
2. The Popular Tab (left panel) will have option to turn on the Developer Tab
1. Using Form Controls – Form controls are extremely easy and intuitive to
use. For example if you see a scrollbar you don’t need an Einstein brain to
figure out what to do with it.. Its simple.. Just scroll baby, just scroll up and
down
2. Creating Form Controls – Now here is where you will require some
geniuses because you need to connect that scrollbar to your data in excel
so that when the user is using it, it populates correct data
© Goodly www.goodly.co.in 61
Form Controls
Creating Form Controls – Form controls are found in the Insert Tab drop
down in the Developer Tab
You can pick any form control and cursor icon will change to a plus sign.
Simply drag the plus sign on the sheet and Form Control will be drawn. No
rocket science, its very intuitive!
© Goodly www.goodly.co.in 62
Form Controls
1. Button
Looks and works like any button. So what would happen if you press the
(on/off) button on your laptop.. Yeah right your laptop will turn ON or it will
turn OFF? .. Getting smarter.. Huh?
Just as the way buttons work in real life.. They do something. The excel Form
Control Button will also do something. Now that something comes from a
Macro so as soon as you draw the Button control excel will populate an Assign
Macro window to assign some Macro (that will do something) to that button
you just created. When you press the button that macro will run
Here we are setting our bounds to some crazy out of the box stuff without
using VBA
2. Combo Box
I am sure you are familiar with the List option in Data Validation which creates
a drop down, the combo box is just a bit different. The format control gives 3
design options to link this with the spread sheet
40+ records
© Goodly www.goodly.co.in 63
Form Controls
Step 2) Open the format controls of the combo box inserted and select the
data from the sheet, link it to cell in the sheet and specify the drop down lines
Step 3) Now when you click the combo box dropdown it will show the list
drop down of the EMP IDs we just need to connect the drop down to a formula
that fetches the correct grade for that ID.. Which is our regular INDEX or a
VLOOKUP (you are already a pro at it)
A simple index
formula to get the
desired Grade for
the Emp ID selected
We’ll this could have been done without the combo box as well.. but at times
combo box serves as a great utility in dashboards and automation reports!
© Goodly www.goodly.co.in 64
Form Controls
3. Spin Button
They are pretty simple to construct, but they can only be constructed like a
portrait. By looking at spin button you can realize that it is meant to increase
or decrease a particular value
Let’s create a spin button and open the Format Control box
4. Option Button
Option button are meant to give the user the flexibility of choosing an option
between some. You can insert as many option button on a single sheet and
link them all to a single cell. Lets insert 4 option buttons on the sheet and
work with them
Apart from inserting 4 option buttons
I have also renamed them by right
clicking and choosing Edit Text option
The format Control box gives us the only option to link each of the Option
button to a single cell in the sheet
© Goodly www.goodly.co.in 65
Form Controls
When you change the value of the Option Button the value updates in the
linked cell
Note that the linked cell picks up the value as per the
order of options button inserted.. So the option button
inserted first will by default have the number 1 and so n.
The cell value has nothing to do with the text that you
enter to name the option button
4. List Box
The list box can hold a list of values (some) visible at a time (if your list is
large) and lets the user choose any one of the list item. Depending the
number of the item chosen (from top to bottom) it will give its sequence
number. Lets explore this as well
5. Check Box
The check box lets you check and uncheck the button and return a
TRUE/FALSE Boolean where TRUE means 1 and FALSE means 0. The format
controls of the Check Box looks like this
© Goodly www.goodly.co.in 66
Form Controls
6. Scroll Bar
The scroll bar scrolls a particular value up or down. You can insert the scroll
bar horizontally or vertically. Lets first get the format control basic right and
then delve into an interesting case
The value appears as per the scroller’s
position in the bar
Change in value
when you click the
corner arrows
150 records
Step 1) Create a vertical scroll bar and link it to a cell in the sheet
© Goodly www.goodly.co.in 67
Form Controls
Step 2) Add row numbers next to the scroll bar. Use the =ROWS function with
an expanding array (freeze only the first part of the range)
Step 3) Write a simple INDEX formula to pull the records from the table. Lets
see how the INDEX formula is working
1 2 3 4
• It is taking the array on the data range specified
• The row number is deriving from the ROWS function used and we are
adding the value in the cell linked to the scroll bar.
o WHY ? Because when you scroll down.. The value will change (2,3,4,
and so on) the new value will then be added to the ROWS function
that is being fed into the INDEX… phew!! Too much is it??
• The column number is 1 for the Names and should change to 2 (manually)
when to copy the formula right to fetch the CTCs
This trick is incredibly helpful in dashboards, you can further compact the
formula by consolidating the logic in a single formula and may be using the
MATCH function to fetch the column numbers
© Goodly www.goodly.co.in 68
7. Pivot Tables
69
Pivot Tables
In my opinion Pivot Table’s usage has been mixed. Some live and sleep with it
and some shy away. I am going to discuss some basic stuff and more of
unconventional advanced stuff in this topics. Let’s see if I can spurt your love
for pivot tables ?
~600 such
records
But this kind of pivot table wont be of much help since the dates are not
showing in quarters and years. So Let’s group them
1. Right click on the dates in the pivot table data and choose Group
2. Then Group it with quarters and years
© Goodly www.goodly.co.in 70
Pivot Tables
Once you have done the grouping the data will show something like this.
Beautiful.. Just as we wanted!
Just as this
you can do
grouping in
multiple ways
This was cool, lets check out some problems that you might face with
grouping. Lets create another pivot table on a different sheet with the same
data and try and group the dates into months and years this time
Notice 2 things
© Goodly www.goodly.co.in 71
Pivot Tables
The solution is to separate the grouping for each pivot table, so we are going
to go back in 2003 and take the solution from there. Old is gold!! Lets create a
pivot table like the way it was done in version 2003. The shortcut was ALT D
P. It will pop with the 3 stage process
3. Now this dialogue box is important. If you read the message it says you’ll save
memory if you choose to keep the same grouping as the other pivot table but
that is exactly that we don’t want to do.. So choose NO
After you are done with this process you can freely group the dates in a
different date structure
© Goodly www.goodly.co.in 72
Pivot Tables
The grouping feature also can split the data in class intervals. Take a look at
this case
We want to find the number of people
in the following categories
• 20-24
• 25-29
• 30-34
• 35-40
© Goodly www.goodly.co.in 73
Pivot Tables
The problem occurs when the data (numbers) are in decimal units
We want to find the number of people
in the following wage categories
• 20-24
• 25-29
• 30-34
• 35-39
Tweaked the data • 40-44
a bit with Names
and Wage/Hour
We follow the same pattern to add Age to Rows Field and Name to the Values
field in the pivot table
Take a look at the class intervals and answer the
following question
When the grouping feature in pivot tables are dealing with decimal numbers
the categories are created in continuous forms but our question is still
unanswered. In this kind of grouping lower limit is included and upper limits is
not included in category. So the value 30 will belong to category 3
If I have to explain slicers, I would say they are better looking filters that can
be applied on pivot table reports. Consider this Pivot Table report of our initial
data with date as years in columns and customers in rows
© Goodly www.goodly.co.in 74
Pivot Tables
Find slicer option the Insert Tab. As soon as you click on slicer excel will throw
a dialogue box asking on which field do you want to apply slicers?
© Goodly www.goodly.co.in 75
Pivot Tables
Check out the timelines are inserted on Dates. You can select partial period to
display adequate data. You can also change the unit of the date from months
to quarters to even days
1. Select the slicer that you want to connect or disconnect and go Options Tab
(only highlights when you select the slicer)
2. Click on Report Connections
3. In the dialogue box pick up the pivot tables where you want to link the
slicer
© Goodly www.goodly.co.in 76
Pivot Tables
Now that we have looked at some unique features of Pivot Tables lets grab
some calculations too
Running Totals
Let’s say we have grouped the dates by month and years and calculated sales
Running Total
Jan (214100)
Jan + Feb (214100 + 122500)
Jan + Feb + March (214100 + 122500 + 196450)
And so on.. For all years
This is what we want!
© Goodly www.goodly.co.in 77
Pivot Tables
Then select the running total on dates and your sales column will be replaced
by running total grouped by years. Just add sales again to your value field to
have two columns – one for running total and the other for sales
Sales column
Just as running total we also have difference from calculation, lets check
that out. I have restored the earlier monthly sales and now we want to take
the difference from the last month
Difference From Last
Month
0
154900
-30800 The additional column is telling us if
83400 the sales have increased or decreased
-154700 from the last month
212850
-145750
8100
© Goodly www.goodly.co.in 78
Pivot Tables
Right click on the sales and choose Show Values as Difference from
option click on Previous in the dialogue box OK
Be sure to choose
previous for calculating
the difference from the
previous month
You might want to check out some other interesting options like
• Ranking of the data
• % Difference from (to calculate the % change)
• % Running total (to calculate % additions)
• Many more useful operations depending on your needs
© Goodly www.goodly.co.in 79
Pivot Table – Data Models
Finally we now come to a bird called Data Model in Pivot Table. This bird is
found in excel 2013 and beats the shit out data analysis.. Guys here is
DATA MODEL
Jokes apart, data model feature really takes the analysis capabilities of pivot
table to another level. Lets begin with an example
Now convert the data in Excel Tables (refer to the tables reading) by pressing
Ctrl + T
• Name the Sales table as mysales
• Name the Customer table as Customers
Make a pivot table from the sales data and be sure to check the data model in
the Pivot Table dialogue box
© Goodly www.goodly.co.in 80
Pivot Table – Data Models
Let’s keep some the data model aside for a while and lets get our head around
a couple of concepts
Primary Key – Sound like you have heard it ?? It is the genesis of forming
data relationships. Anything item which is unique and exists in a set of data is
a primary key. Could you guess what is the primary key in our sales data ?
If you have guessed
correctly, there is
no primary key in our
sales data, since no
unique field exists
Ok how about the customer data, what is the primary key here ?
The primary key here is the
customer code. If you are
thinking the primary key to be
Customer Name, which is wrong
because in the real world the
customer names can be same (but
as of now they are not repeating)
Foreign Key – would be the repeated records in table which can be uniquely
identified by records in another table.. Eh?? Ok ok sorry for the weird
definition take a look at the example.
Customer Code in Sales Table is a Foreign Key, WHY ? because the records are
repetitive but if I want to bring together all the transaction of a particular
customer code together I have a customer table with unique customer code
that matches with the customer codes (multiple entries) in the sales table!! I
hope you got it this time.. NO?? Read again, slowly, you’ll get it
Customer Code in mysales table is the foreign key that can be identified uniquely
with the Customer code in customers table
© Goodly www.goodly.co.in 81
Pivot Table – Data Models
Coming back to our pivot table. Take a look at the pivot table field list, Mysales
table has been added. Note a few visual and conceptual difference
1. A little table symbol in front of MySales – displaying column headers in it
2. A separate tab for Active tables and All tables
This way you can do multiple tables and link them in a single pivot table. Just
a couple of things before I close on Pivot Tables
• Identical data type in both columns: Columns that you are connecting in
both tables should have same data type (i.e. both numbers or dates or text
etc.)
• One to one or One to many relationships only: Data Model works with
only one to many or one to one relationships. That means one of the tables
must have no duplicate values on the column you are linking to
© Goodly www.goodly.co.in 83
8. Custom Formatting &
Applications
84
Custom Formatting and Applications
This feature allow you the change the way how your data appears.. Something
like before and after make up transformation
But just as the old and wise say.. Make up does not change who you really
are! So does it apply to custom formatting, it does not change the underlying
data but only changes how it looks (and this is really important to remember)
© Goodly www.goodly.co.in 85
Custom Formatting and Applications
We’ll discuss how to make a code in while but let’s discuss some ground rules
first!!
You don’t necessarily need to write the code for all 4 parts. Excel will assume
the following in case you choose to omit one or more parts of the code
1. If you writing only the first part – then it applies to all numbers (+ve, -
ve and zeros)
2. Writing only first and second part – then first part formats +ve
numbers and zeros and second part formats the -ve numbers
3. Three parts – 1st formats the +ve numbers, 2nd formats the -ve
numbers, 3rd formats the zeros
Thumb Rule 2) You have to follow the sequence while writing the code. I
mean you cannot write the code for a text first and then for a negative
number… it wont work!! So the sequence for all 4 parts of the code will be
Positive Number Code ; Negative Number Code ; Zero Code ; Text Code
Thumb Rule 4) Put the text in the code in double quotes, example “Mn”
1. Stacey (even if you are not Stacey :-D ), all the positive sales/profit
numbers should appear this way – $ 173.0 Mn
2. All negative numbers should appear this way in red color - $ (14.0) Mn
3. All zeros should be replaced with a hyphen -
© Goodly www.goodly.co.in 86
Custom Formatting and Applications
According to the rules our code will follow this sequence
positive number code ; negative number code ; zero code
Code for negative numbers Now negative number need to be in red and in
brackets, rest is the same as positive number coding
Thumb Rule 5) When applying color to any part of the code, make sure the
color is written first in square brackets [Red]
Finally Code for zeros We don’t need to see zeros, instead we want a hyphen
or a dash so our revised quote looks like $ 0.0 “Mn”;[Red] $ (0.0) “Mn”;-
Note: code is separated with semicolon. Press Ok and see the result
Displays only significant digits and does not display insignificant zero’s, for example it
#
won’t display 0001 rather will display 1
Displays both significant (non zero numbers) and insignificant zero’s, for example the
0
code 000 will display 001,002 and so on
Decimal separator shows the number of decimal places after the number, for
.
example 0.0 will show insignificant zeros and 0.# will only significant decimal places
Comma if suffixed after # or a 0 it divides the number by 1000, for example 0, “k” will
,
result the number (15000) in 15 k
The percentage (%) symbol multiplies the number by 100 and suffixes the number with
%
a % symbol, for example #.0% will result in 12.0%
© Goodly www.goodly.co.in 87
Custom Formatting and Applications
Date & Time Characters and their utility
dd Shows the number of the day in 2 digit places. For example 07, 09, 15
ddd Shows the day in words. For example Sun, Mon, Tue
dddd Shows the day as unabbreviated. For example Monday, Tuesday, Friday
mmm Shows the month as a short word, example Jan, Feb, Mar
mmmm Shows the month as a complete word, example March, April, September
Show the last digits of the year, for example 2014 will be shown as 14 and 2000 as
yy
00
[h] Shows the total hours, for example a number (2) formatted as [h] will show 48
Shows the minutes. Note it only shows minutes if used as time formatting code (hh
m
mm ss) otherwise it shows single digit months
Shows minutes as a two digit number. Note it only shows minutes if used as time
mm
formatting code (hh:mm:ss) otherwise it shows single digit months
Shows the total minutes, for example a number (2) formatted as [m] will show
[m]
2880
S Shows seconds
Shows the total seconds, for example a number (2) formatted as [s] will show
[s]
172800
© Goodly www.goodly.co.in 88
Custom Formatting and Applications
Adding Conditions to your custom formatting code !
This is a real game changer and alters some of the thumb rules that have
been with us this far. In custom formatting you can also apply conditions
if the number is > than 100 then color is red else color is blue
© Goodly www.goodly.co.in 89
Custom Formatting and Applications
Fractions in Custom Formatting
Number in Custom
Result
the Cell Formatting Code
2 # ?/2 2
© Goodly www.goodly.co.in 90
9. Sheet Protection
91
Sheet Protection
If you want to prevent the user from accidentally or deliberately editing or
deleting important data (cells) from your worksheet, you can protect certain
or all cells, with or without a password
Lets say we have Loan Rate, Amount and Interest (Calculated) in a sheet and
you wan that the user should not be able to edit the formula in the Interest
calculation. This is how you would do it
3
1
© Goodly www.goodly.co.in 92
Password Protect Different Ranges
You can also protect different ranges with different passwords. It’s called Allow
Users to Edit Ranges and found in the Review tab
Lets say we have 4 regions where each region will have a different user enter
the data
1. In Review tab in
the Changes group > Click
on Allow Users to Edit
Ranges button
© Goodly www.goodly.co.in 93
Thank you for reading…
Let me know if you have any questions or even if you would like to drop in
a “hi”, I am active on [email protected]
Hey, feel free to send this e-book over to your folks / excel nerds
Apart from delivering live training sessions for companies, I also run online
training courses on Mastering Excel and Business Intelligence Dashboards.
If you want to acquire top notch excel skills you much check them out
www.goodly.co.in
© Goodly www.goodly.co.in 94