Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Office 365. 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 October 23, 2019)


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, 2016, 2019, and Excel in Office 365. 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. ...


Adding a Little Color

The normal way to change the color of selected text is through the use of the Font Color tool. If you have to use the ...

Discover More

Understanding Footnotes and Endnotes

Footnotes and endnotes are often used in scholarly and formal writing as a way to provide additional information about a ...

Discover More

Using Fields for Fractions

Want a quick way to create fractions? You can do it by using fields, as described in this tip.

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (ribbon)

Generating Double-Digit Random Numbers

Normally you use the RAND and RANDBETWEEN functions to generate random numbers. What if you want to generate random ...

Discover More

Adjusting Formulas for Top-Added Rows

Formulas are the heart of using Excel, and formulas often refer to ranges of cells. How you insert cells into the ...

Discover More

Inserting Dashes between Letters and Numbers

If you need to add dashes between letters and numbers in a string, the work can quickly get tedious. This tip examines ...

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 four more than 9?

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.