You’ll find this edition’s tip very useful if you’re one of those who like to include a few paragraphs of text in your worksheets. Excel wasn’t really designed for this (that’s why Microsoft gave us Word) but sometimes there’s no avoiding it, particularly if you’re, say, preparing a report which is predominantly numbers, tables and charts but which requires some narrative too.
This month’s trick uses an underused built-in function but pushes it to do something it probably wasn’t designed for; to sum only numbers which meet certain criteria.
As always, the features covered here are based on Excel 2003 however most can still be found in other versions.
For more information, please contact +61 2 9080 4050, edinfo@iir.com.au , or visit: http://bit.ly/iired
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
Excel Tip: Adder Control
1. E-TIPS
Finance, Valuation, Risk & Modelling
your one-partner solution for building skills and knowledge
Change Your Life with Excel
Adder Control
elcome to Change Your Life with Excel.
You’ll find this edition’s tip very useful if you’re
one of those who like to include a few paragraphs of text
in your worksheets. Excel wasn’t really designed for this
(that’s why Microsoft gave us Word) but sometimes
there’s no avoiding it, particularly if you’re, say, preparing
a report which is predominantly numbers, tables and
charts but which requires some narrative too.
This month’s trick uses an underused built-in function but
pushes it to do something it probably wasn’t designed for;
to sum only numbers which meet certain criteria.
As always, the features covered here are based on Excel
2003 however most can still be found in other versions.
Tip
Embedding Text in a Worksheet
Have you ever had to type a sentence or short paragraph
into Excel and got frustrated with having to manually
break lines? If so, this very quick and easy tip is for you.
It’s one of the quickest tips I’ve covered but requires a bit
of a cheat since we have to start off using Word.
• Open Word and type your required text. Use all
the formatting you need e.g. bullet points, fonts,
line spacing etc
• Highlight all the text and select Edit | Copy from
the Menu Bar
• Switch back to Excel and select the cell where
you want your text to be pasted
• Select Edit | PasteSpecial from the Menu Bar
• From the options available select Microsoft
Office Word Document Object
• Click OK
It looks like a simple text box has been pasted into your
worksheet but it’s much more than this. Notice that when
you double-click anywhere within the text you’ve just
pasted, your Excel Menu Bar and Toolbars become the
Word Menu Bar and Toolbars! What you’ve done is to
seamlessly embed a Word document inside your Excel
document which you can edit with all the functionality of
Word – you don’t even have to return to Word to make
any changes.
The huge advantage of using this technique is that all the
formatting you associate with Word is available to you
from within Excel (have you ever tried adding bullet
points in Excel?).
W
By Leigh Drake
Director
Arc Business Processes
www.arcbusiness.com.au
2. E-TIPS
Finance, Valuation, Risk & Modelling
your one-partner solution for building skills and knowledge
Note that by default a border appears around the edge of
the pasted text. To remove this:
• Right click once within the text and select
Format Object
• From the Format Object dialog box choose the
Colors and Lines tab
• Click the Line Color drop down arrow and select
No Line
• Click OK
Trick
Summing Numbers using Multiple Criteria
Many of you may be familiar with a built-in function called
SUMIF which allows you to add a range of values which
satisfy a single criterion e.g. add all the numbers in a list
which are greater than 100.
However, what if you need to add values based on more
than one criterion? For this we need to use a rather
under-utilised function called SUMPRODUCT. This
function is designed to take 2 or more ranges of values,
multiply them together and total the result. For example
in the illustration below SUMPRODUCT(A1:A4,B1:B4)
would calculate:
12x10 + 20x14 + 6x5 + 4x23 = 522
However, we’re going to take advantage of a quirk in
Excel which will allow us to use this function to sum
values based on multiple criteria.
Using the illustration below, suppose we want to add all
Laptop sales greater than 100 units. The 2 criteria here
are that:
1. Item = “Laptop”; and
2. Units > 100
I’ll tell you how to write the function and then explain how
it works.
Select the cell in which you require the answer and type:
=SUMPRODUCT((A2:A10="laptop")*(B2:B10>100),B2:B10)
The answer is 451, which you’ll see is correct if you look
at the data - there are 2 entries for laptops with sales
units greater than 100; 163 units and 288 units.
The first part of this function multiplies 2 expressions
together.
The first expression, (A2:A10="laptop"), looks at each
value in the range A2 to A10 and determines whether it
contains the value “laptop”. It returns a value of true or
false for each item i.e. false,true,false,false,true... (note
that the 2
nd
, 5
th
and 9
th
values are true because the value
“laptop” appears as the 2
nd
, 5
th
and 9
th
item).
Similarly the 2
nd
expression, (B2:B10>100), returns
false,false,true,false,true... (note that the 3
rd
, 5
th
and 9
th
values are true because the 3
rd
, 5
th
and 9
th
values in the
range B2 to B10 are greater than 100).
Finally B2:B10 just represents the range of values to sum
based on the above criteria.
So how does this all combine to give us our required
answer? This is where we take advantage of that Excel
quirk. We can write formulas and functions in Excel which
give answers of true or false but when we use these in
other formulas, a value of true is treated as a 1 and an
answer of false is treated as a 0. This is what happens
when we multiply (A2:A10="laptop") by (B2:B10>100). As
illustrated below this gives a series of 1’s and 0’s.
3. E-TIPS
Finance, Valuation, Risk & Modelling
your one-partner solution for building skills and knowledge
A2:A10="laptop" B2:B10>100
FALSE X FALSE = 0
TRUE X FALSE = 0
FALSE X TRUE = 0
FALSE X FALSE = 0
TRUE X TRUE = 1
FALSE X FALSE = 0
TRUE X FALSE = 0
FALSE X FALSE = 0
TRUE X TRUE = 1
The SUMPRODUCT function now works as normal by
taking all these 1’s and 0’s and multiplying them by the
range of values in the 2
nd
part of the function, B2:B10 i.e.
0x93 + 0x90 + 0x177 + 0x87 + 1x163 + 0x76 + 0x78 +
0x17 + 1x288
This gives the required answer of 451.
This example only uses 2 criteria but you can use almost
as many criteria as you need. To use 5 criteria for
example you would simply multiply your 5 expressions
together in the first part of the SUMPRODUCT function.
Look out for more great Excel tips and tricks next month.
Until then, happy Excelling!