Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, and 2016. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Cell and Name References in COUNTIF.

Cell and Name References in COUNTIF

by Allen Wyatt
(last updated December 26, 2015)


Larry has a worksheet that uses the COUNTIF function extensively. A typical use would be similar to the following:


This works fine, but Larry would like to specify the second parameter using a cell or name reference, as in ">=B3" or ">=Goal". Problem is, Larry can't get those types of references to work.

Indeed, if you use the following syntax for COUNTIF, you will not get the results you want:


The reason is because everything within the quotes is considered to be part of a string literal. In other words, B3 doesn't (in this case) represent a cell reference, but the two characters B and 3.

The solution is to take the cell reference outside of the quote marks, in this manner:

=COUNTIF(B5:B25,">=" & B3)

In this case the B3 is not literal, but a reference to the contents of cell B3. If, for instance, cell B3 contains the value 49, then this instance of COUNTIF is translated in this manner:


If you want to use a cell reference in the formula, and you will be copying that cell reference elsewhere in your worksheet, then you may want to make sure that you use an absolute reference to the cell, as in this usage:

=COUNTIF(B5:B25,">=" & $B$3)

That way you can copy the formula without Excel changing the B3 cell reference to some other cell. You can similarly use a named cell reference in your formula using the same technique:

=COUNTIF(B5:B25,">=" & Goal)

If you prefer, you could also simply put a criteria for COUNTIF in the cell you are referencing. For instance, cell B3 could contain the text ">=49", without the quote marks. You could then simplify your use of COUNTIF in this manner:


ExcelTips is your source for cost-effective Microsoft Excel training. This tip (11417) applies to Microsoft Excel 2007, 2010, 2013, and 2016. You can find a version of this tip for the older menu interface of Excel here: Cell and Name References in COUNTIF.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...


Finding the Address of the Lowest Value in a Range

Uncovering the lowest value in a range is relatively easy; you can just use the MIN worksheet function. Discovering the ...

Discover More

Replacing Characters at the End of a Cell

The Find and Replace capabilities of Excel can come in handy, but they can't accomplish all your replacement needs. One ...

Discover More

Turning Off Automatic Captioning

Word can be configured so that it automatically adds captions to some of your design elements (tables, figures, etc.). ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

More ExcelTips (ribbon)

Replacing Dashes with Periods

Replacing one character in a text value with another character is easy. All you need to do is use the SUBSTITUTE ...

Discover More

Applying Range Names to Formulas

If you define your named ranges after you create your formulas, you can have Excel update those formulas to reflect the ...

Discover More

Counting Cells with Specific Characters

Excel is used by many people to hold all sorts of data, not just numbers. If you have cells that include meaningful ...

Discover More

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.


If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is nine more than 3?

2017-05-04 17:38:12

Wanda Smith

I'm wanting to learn how to set tickler/alert notifications for instance. I need to be alerted within 90 days of a lease being up for renewal.
This would be in Excel 2011 for Mac.
Thank you so much!!!!

2017-04-04 11:38:11


Thank you Allen! Separating out the formula using an &, and re-arranging the "s solved my countif formula issue.

2017-01-12 10:51:14

Rickey Hargrave

Thank you, Peter. This really helps.

2017-01-11 11:22:53

Peter Atherton

Try this

Time CCM-DNR Blue Death Request Follow-Up Total
7:59 0 0 0 0 0 0
16:00 4 2 3 7 1 17
23:59:00 3 0 1 1 0 5
Totals 7 2 4 8 1 22
L2 =SUMPRODUCT(--($F$2:$F$23<=$K2)*($G$2:$G$23=L$1))
L3 =SUMPRODUCT(--($F$2:$F$23<=$K3)*($F$2:$F$23>=$K$2)*($G$2:$G$23=L$1))
L4 =SUMPRODUCT(--($F$2:$F$23>$K$3)*($F$2:$F$23<=$K4)*($G$2:$G$23=L$1))

2017-01-11 07:49:51


Thank you Peter and Micky. Peter, your formula is cleaner than my original, but it still gives me the result 2 instead of 3. Cell 6 is definitely included in my range. I'm puzzled about why Excel doesn't see that value.

Micky, your array formula works. I don't really understand why, but at this point I don't care! Ha!

2017-01-11 05:57:11

Michael (Micky) Avidan

Try my suggestion shown in the attached picture.
(see Figure 1 below)
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2017)

Figure 1. 

2017-01-10 18:47:07

Peter Atherton


Your formula works well and you need the stars. Here is another formula to search for the value in B1

Are you sure that cell 6 is included in the range?

2017-01-09 17:01:21

Rickey Hargrave

I use this formula to determine which Chaplain (in this case Chuck) handled (Death calls).
Now to figure out how to put in the time parameters.

2017-01-09 16:57:20

Rickey Hargrave

I have a large spreadsheet and want to know the time periods calls come in. Between 00:00 and 07:59; 08:00 - 16:00; and 16:01 - 00:00. how many deaths occur between those hours, how many "Requests", etc. Here is the spreadsheet portion.
Date Chaplain Age Sex Room Time In Reason FH / Notes
1/1/2016 Chuck 78 m 201 8:30 CCM-DNR
1/1/2016 Chuck 58 m 232 9:15 CCM-DNR
1/1/2016 Chuck 88 f 205 19:00 CCM-DNR
1/1/2016 Chuck 88 f 401 8:00 Code Blue
1/1/2016 Chuck 72 m ER 14:00 Code Blue SI/GSW
1/1/2016 Chuck 83 f 833 12:15 Death American
1/1/2016 Chuck 58 m 232 17:10 Death Wise
1/1/2016 Chuck 69 m 8:45 Follow-Up
1/1/2016 Chuck 69 f 601 10:40 Request Patient
1/1/2016 Chuck 63 m 211 15:40 Request Family
1/1/2016 Chuck 69 m 218 16:50 Request Family
1/2/2016 Chuck 65 m 209 12:15 CCM-DNR
1/2/2016 Chuck 61 m 213 13:55 CCM-DNR
1/2/2016 Chuck 94 f 825 17:15 CCM-DNR
1/2/2016 Chuck 78 m 803 12:45 Death Waldo
1/2/2016 Chuck 69 f 601 10:40 Request Family
1/2/2016 Chuck 65 m 624 11:00 Request Family
1/2/2016 Chuck 49 f 217 11:30 Request Family
1/2/2016 Chuck 63 m 211 11:45 Request Family
1/2/2016 Chuck 86 f 220 14:40 Request Family
1/3/2016 Chuck 90 m 813 18:15 CCM-DNR
1/3/2016 Chuck 80 m 703 12:50 Death Bratcher

2016-08-19 04:20:16


Good tips, really work.

2016-05-06 11:37:02


In a named range ("DIGITS"), I'm trying to count how many times 10388552 appears. I'm using the formula =COUNTIF(DIGITS,"=*10388552*").

The data looks like this:
cell 1: 10388596, 10388498, 10388552, 10385922
cell 2: 10388596, 10388498, 10388552, cell 3: 10385922
cell 4: 10388596, 10388498
cell 5: 10388596, 10388498
cell 6: 10388552

The result should be 3, but it's giving me 2. It will not count the value in cell 6 unless I take out the * in the formula.

2016-01-07 09:39:39


Thanks for this tip. I have spent hours working trial and error to get this kind of criteria to work. I don't do it a lot so I don't always remember where I've done one before and have to recreate the "wheel" each time. I'm putting this one in my personal help files.

This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.