You are on page 1of 31

Get weekly Excel tips, tutorials, videos, and news

Contextures Excel Newsletter

Online Instruction Page


How to Count in Excel
Related Excel Product
30 Excel Functions in 30 Days eBook Kit
Examples
COUNT COUNT NOT ""
COUNTA COUNTIFS
COUNTBLANK COUNTIFS_Crit
COUNTIF Exact MonthYear
COUNTIF Wildcard COUNTIFS Date
COUNTIF Operator SUBTOTAL
COUNTIF Range AGGREGATE
DupsFalse SUBTOTAL2
NumInNum MyLinks
SUMPRODUCT
Qty Count Cells with Numbers -- Excel COUNT
50

5.5
10

www.contextures.com

Developed by Contextures Inc. www.contextures.com 12/18/2018


Qty Count Cells with Data -- COUNTA
50

5.5
10

www.contextures.com

file:///conversion/tmp/scratch/404930602.xlsx 12/18/2018
Qty Count Blank Cells -- COUNTBLANK
50

5.5
10

www.contextures.com

file:///conversion/tmp/scratch/404930602.xlsx 12/18/2018
Item Qty Count cells that match criteria -- COUNTIF
Pen 5 Match criterion exactly
Pencil 9
Binder 9
Pen 6
Pen 15
Binder 12
Pencil 10
Binder 6
Pen 11

4
www.contextures.com
Item Qty Count cells that match criteria -- COUNTIF
Pen 5 Match criterion in a string
Pencil 9
Binder 9
Pen 6
Gel Pen 12
Binder 12
Pencil 10
Binder 6
Pen 11

6
6 pen <==enter a text string in the yellow cell, e.g. "pen"

www.contextures.com
Item Qty Count cells that match criteria -- COUNTIF
Pen 5 Criterion and operator
Pencil 9
Binder 9
Pen 6
Pen 15
Binder 12
Pencil 10
Binder 6
Pen 11

www.contextures.com
Item Qty Count cells that match criteria -- COUNTIF
Pen 5 Match criteria in a range
Pencil 9
Binder 9
Pen 6
Pen 15
Binder 12
Pencil 10
Binder 6
Pen 11

6
www.contextures.com
Code Dup COUNTIF Dup SUMPRODUCT
123 0 0 The second argument of COUNTIF is
00123 1 0 treated as text, so you might see false duplicates
234 0 0 such as 00123 = 123
567 0 0
00567 1 0 Use SUMPRODUCT to avoid this, where necessary
0000234 1 0
0234 1 0
5678 0 0
000234 1 0
List Type Count Numbers in Other Numbers
12345 Num Find specific numbers or letters within other numbers or text strings
A12345 Text
a12345 Text Count: 1 In the list, 4 items contain "1" (case-sensitive)
B23456 Text In the list, 4 items contain "1" (NOT case-sensitive)
12345 Text
23456 Num Use SUMPRODUCT with ISNUMBER and FIND or SEARCH
Use FIND to count numbers, or case-sensitive letters
4 =SUMPRODUCT(--ISNUMBER(FIND($E$4,$A$2:$A$7)))
Use SEARCH to count numbers, or upper and lower case letters (not case-sensitive)
4 =SUMPRODUCT(--ISNUMBER(SEARCH($E$4,$A$2:$A$7)))

COUNTIF does NOT count numbers within a number, just in a text string
When looking for "1", COUNTIF gives an incorrect result -- 3 -- because it doesn't count cell B2
3 =COUNTIF($A$2:$A$7,"*" & E4 & "*")
se-sensitive)

it doesn't count cell B2


Item Qty Count cells that match multiple criteria -- SUMPRODUCT
Pen 5
Pencil 9 Pen 10
Binder 9
Pen 6
Pen 15
Binder 12
Pencil 10
Binder 6
Pen 11

2
www.contextures.com
SUMPRODUCT
Item Qty Sold Count cells that do not contain an empty string
Pen 5 Pen
Pencil COUNTIF <> 9 <== counts text and empty strings
Binder 9 Binder COUNTIF <> & "" 9 <== counts text and empty strings
Pen 6 Pen COUNTIF >=! 5 <== counts cells with text >= ! (char
Pen COUNTIF ?* 5 <== counts cells with at least one ch
Binder 1
Pencil 10 Pencil COUNTA 9 counts all text, including empty string
Binder COUNTBLANK 3 counts empty strings as if blank
Pen 11 Pen Difference 6 subtract empty cells from total count

www.contextures.com SUMPRODUCT 6 <== use SUMPRODUCT to count c

3
Code Character
32
33 !
34 "
35 #
36 $
37 %
38 &
39 '
40 (
41 )
42 *
43 +
44 ,
45 -
46 .
47 /
48 0
49 1
50 2
51 3
52 4
53 5
54 6
55 7
56 8
57 9
58 :
59 ;
60 <
61 =
tain an empty string ""
unts text and empty strings
unts text and empty strings
unts cells with text >= ! (char 33)
unts cells with at least one character

ll text, including empty strings


mpty strings as if blank
empty cells from total count

e SUMPRODUCT to count cells that don't contain empty string


Item Qty Count cells that match multiple criteria -- COUNTIFS
Pen 5 For Excel 2007 and later versions only
Pencil 9 Pen 10
Binder 9
Pen 6
Pen 15
Binder 12
Pencil 10
Binder 6
Pen 11

www.contextures.com
COUNTIFS
Day Region Qty Problem Count cells with any text in one column,
Mon East 95 late specific text in another column -- COUNTIFS
Tue West 150 For Excel 2007 and later versions only
Wed West 137 hold
Thu West 112 Region East
Fri Central 57 defects
Mon West 69 Problems 2 East Region Problems
Tue East 126
Wed East 130 shortage Qty 471 Sum for East region
Thu East 120
Fri West 84 Count 4 Count of East region

Problems 2 SUMPRODUCT -- ignores empty strings created by formu


To see the difference, type ="" in cell D10
G7 will change, to show 3 problems
rings created by formulas
Date Orders for Month & Year Count cells in specific month and year -- SU
3/1/2016 3 www.contextures.com
OrderDate Product Qty Price Total
1/1/2016 Pen 54 5.00 270.00 Type a date in cell A2
1/22/2016 Binder 15 8.25 123.75 to see a count of orders in that month and year
2/12/2016 Pen 51 5.00 255.00
3/4/2016 Pen 61 5.00 305.00
3/25/2016 Pencil 67 3.50 234.50
3/28/2016 Binder 58 8.25 478.50
5/6/2016 Binder 10 8.25 82.50
5/27/2016 Pen 22 5.00 110.00
5/29/2016 Pen 73 5.00 365.00
7/8/2016 Binder 34 8.25 280.50
7/29/2016 Pencil 25 3.50 87.50
9/1/2016 Pencil 69 3.50 241.50
9/9/2016 Binder 28 8.25 231.00
9/30/2016 Pencil 36 3.50 126.00
12/1/2016 Binder 31 8.25 255.75
12/5/2016 Binder 16 8.25 132.00
12/18/2016 Pen 44 5.00 220.00
12/23/2016 Pen 23 5.00 115.00
1/13/2017 Binder 27 8.25 222.75
2/3/2017 Pencil 43 3.50 150.50
2/24/2017 Pencil 123 3.50 430.50
3/17/2017 Pen 42 5.00 210.00
th and year -- SUMPRODUCT
Product Ship from 15-Aug Total www.contextures.com
Binder to 15-Sep 1

OrderDate Product Qty Price Total ShipDate


5-Aug Pen 54 5.00 270.00 13-Aug
12-Aug Binder 15 8.25 123.75 13-Aug List for Drop Down
19-Aug Pen 51 5.00 255.00 20-Aug Binder
26-Aug Pen 61 5.00 305.00 4-Sep Pen
2-Sep Binder 28 8.25 231.00 11-Sep Pencil
9-Sep Pencil 36 3.50 126.00 16-Sep
16-Sep Binder 31 8.25 255.75 26-Sep
23-Sep Binder 16 8.25 132.00 24-Sep
28-Sep Pen 44 5.00 220.00 1-Oct
29-Sep Pen 23 5.00 115.00 30-Sep
8-Oct Binder 27 8.25 222.75 10-Oct
13-Oct Pencil 43 3.50 150.50 21-Oct
16-Oct Pencil 123 3.50 430.50 20-Oct
18-Oct Pen 42 5.00 210.00 20-Oct

Count cells that match date range criteria -- COUNTIFS


For Excel 2007 and later versions only
Item Units Cost Total Count Rows in a Filtered List -- SUBTOTAL
Pen 5 15 75
Pencil 9 5 45
Binder 9 10 90 In the SUBTOTAL function, 3 as the
Pen first argument is COUNTA. This
15 counts the cells with data that are
Pen 15 15 225 visible after a filter has been
Binder 12 10 120 applied. Even cells with empty
Pencil 5 50 strings are counted, e.g. cell D5.
10
Binder 6 10 60
Pen 11 15 165 In the SUBTOTAL function, 2 as
9 the first argument is COUNT. This
counts the numbers that are visible
8 after a filter has been applied.

www.contextures.com
List -- SUBTOTAL
Count: 2 AGGREGATE - ignore errors

Item Units Cost Total Count Rows in a Filtered List -- AGGREG


Binder 9 10 90
Binder n/a 10 #VALUE!
Binder 6 10 60

=AGGREGATE(3,3,Table1[Total])

www.contextures.com
tered List -- AGGREGATE
Item Units Cost Total Count Visible Items in a Filtered List
Pen 15 15 225
Binder 12 10 120
Pen 11 15 165

Pen #VALUE!
The Total column is filtered for
amounts greater than 100.
The SUMPRODUCT formula
www.contextures.com
counts only the visible
occurrences of Pen in cells
A1:A10
Filtered List
Contextures Products
Pivot Power Premium Add-in
UserForms for Data Entry ebook Kit
Contextures Excel Tools Add-in
Data Entry Search Popup
Data Entry Popup
30 Excel Functions in 30 Days eBook Kit

Contextures Sites & News


Contextures Excel Newsletter
Contextures Excel Tips Website
Contextures Excel Blog
Excel Pivot Tables Blog

Other Excel Products


Contextures Recommends

www.contextures.com 12/18/2018
Time-saving tools for pivot table power users
Step by step instructions and videos
Make instant backups, sort sheets, and many more tools
Makes data entry easier when choosing from long list
Select single or multiple items from a listbox, to enter in a single cell
Sample workbook and easy to follow user guide for key Excel functions

Weekly Excel tips, tutorials, videos, and news


Hundreds of tutorials, tips and sample files
Read the Excel tutorials and share your comments
Pivot table tutorials and tips, with comments and questions

Other Excel tools and training, recommended by Debra

www.contextures.com 12/18/2018

You might also like