{"id":1782,"date":"2011-10-05T10:06:47","date_gmt":"2011-10-05T10:06:47","guid":{"rendered":"http:\/\/www.microsofttraining.net\/b\/exceltraining\/?p=302"},"modified":"2024-05-12T01:22:55","modified_gmt":"2024-05-12T01:22:55","slug":"using-the-countif-function-in-excel-2010","status":"publish","type":"post","link":"https:\/\/www.stl-training.co.uk\/b\/using-the-countif-function-in-excel-2010\/","title":{"rendered":"Using the Countif Function in Excel 2010"},"content":{"rendered":"<p><strong>Countif<\/strong> Counts the number of cells within a range that meet the given criteria.<\/p>\n<h2>Syntax<\/h2>\n<p><strong>COUNTIF<\/strong>(<strong>range<\/strong>,<strong>criteria<\/strong>)<\/p>\n<p><strong>Range<\/strong>\u00a0\u00a0\u00a0\u00a0is the range of cells from which you want to count cells.<\/p>\n<p><strong>Criteria<\/strong>\u00a0\u00a0\u00a0\u00a0is the criteria in the form of a number, expression, cell reference, or text that defines which cells will be counted. For example, criteria can be expressed as 32, &#8220;32&#8221;, &#8220;&gt;32&#8221;, &#8220;apples&#8221;, or B4.<\/p>\n<h2>Remarks<\/h2>\n<ul type=\"disc\">\n<li>You can use the wildcard characters, question mark (?) and asterisk (*), in criteria. A question mark matches any single character; an asterisk matches any sequence of characters. If you want to find an actual question mark or asterisk, type a tilde (~) before the character.<\/li>\n<li>Microsoft Excel provides additional functions that can be used to analyze your data based on a condition.<\/li>\n<ul type=\"disc\">\n<li>To calculate a sum based on a string of text or a number within a range, use the SUMIF worksheet function.<\/li>\n<li>To have a formula return one of two values based on a condition, such as a sales bonus based on a specified sales amount, use the IF worksheet function.<\/li>\n<li>To count cells that are empty or not empty, use the COUNTA and COUNTBLANK functions.<\/li>\n<\/ul>\n<\/ul>\n<h2>Example 1: Common COUNTIF formulas<\/h2>\n<p>The example may be easier to understand if you copy it to a blank worksheet.<\/p>\n<div>\n<ol type=\"1\">\n<li>Create a blank workbook or worksheet.<\/li>\n<li>Select the example in the Help topic.<\/li>\n<\/ol>\n<p><strong>\u00a0Note\u00a0<\/strong>\u00a0\u00a0Do not select the row or column headers.<\/p>\n<div>Selecting an example from Help<\/div>\n<ol type=\"1\" start=\"3\">\n<li>Press CTRL+C.<\/li>\n<li>In the worksheet, select cell A1, and press CTRL+V.<\/li>\n<li>To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the <strong>Tools<\/strong> menu, point to <strong>Formula Auditing<\/strong>, and then click <strong>Formula Auditing Mode<\/strong>.<\/li>\n<\/ol>\n<\/div>\n<table>\n<tbody>\n<tr>\n<td>\n<div>\n<table id=\"NestedTable1\">\n<tbody>\n<tr>\n<td>\u00a0<\/td>\n<\/tr>\n<tr>\n<th><strong>1<\/strong><\/th>\n<\/tr>\n<tr>\n<th><strong>2<\/strong><\/th>\n<\/tr>\n<tr>\n<th><strong>3<\/strong><\/th>\n<\/tr>\n<tr>\n<th><strong>4<\/strong><\/th>\n<\/tr>\n<tr>\n<th><strong>5<\/strong><\/th>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/td>\n<td>\n<div>\n<table id=\"NestedTable2\">\n<tbody>\n<tr>\n<th><strong>A<\/strong><\/th>\n<th><strong>B<\/strong><\/th>\n<\/tr>\n<tr>\n<td><strong>Data<\/strong><\/td>\n<td><strong>Data<\/strong><\/td>\n<\/tr>\n<tr>\n<td>apples<\/td>\n<td>32<\/td>\n<\/tr>\n<tr>\n<td>oranges<\/td>\n<td>54<\/td>\n<\/tr>\n<tr>\n<td>peaches<\/td>\n<td>75<\/td>\n<\/tr>\n<tr>\n<td>apples<\/td>\n<td>86<\/td>\n<\/tr>\n<tr>\n<td><strong>Formula<\/strong><\/td>\n<td><strong>Description (result)<\/strong><\/td>\n<\/tr>\n<tr>\n<td>=COUNTIF(A2:A5,&#8221;apples&#8221;)<\/td>\n<td>Number of cells with apples in the first column above (2)<\/td>\n<\/tr>\n<tr>\n<td>=COUNTIF(A2:A5,A4)<\/td>\n<td>Number of cells with peaches in the first column above (1)<\/td>\n<\/tr>\n<tr>\n<td>=COUNTIF(A2:A5,A3)+COUNTIF(A2:A5,A2)<\/td>\n<td>Number of cells with oranges or apples in the first column above (3)<\/td>\n<\/tr>\n<tr>\n<td>=COUNTIF(B2:B5,&#8221;&gt;55&#8243;)<\/td>\n<td>Number of cells with a value greater than 55 in the second column above (2)<\/td>\n<\/tr>\n<tr>\n<td>=COUNTIF(B2:B5,&#8221;&lt;&gt;&#8221;&amp;B4)<\/td>\n<td>Number of cells with a value not equal to 75 in the second column above (2)<\/td>\n<\/tr>\n<tr>\n<td>=COUNTIF(B2:B5,&#8221;&gt;=32&#8243;)-COUNTIF(B2:B5,&#8221;&gt;85&#8243;)<\/td>\n<td>Number of cells with a value greater than or equal to 32 and less than or equal to 85 in the second column above (3)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Example 2: COUNTIF formulas using wildcard characters and handling blank values<\/h2>\n<p>The example may be easier to understand if you copy it to a blank worksheet.<\/p>\n<p>Create a blank workbook or worksheet.<\/p>\n<div>\n<ol type=\"1\">\n<li>Select the example in the Help topic.<\/li>\n<\/ol>\n<p><strong>\u00a0Note\u00a0<\/strong>\u00a0\u00a0Do not select the row or column headers.<\/p>\n<div>Selecting an example from Help<\/div>\n<ol type=\"1\" start=\"3\">\n<li>Press CTRL+C.<\/li>\n<li>In the worksheet, select cell A1, and press CTRL+V.<\/li>\n<li>To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the <strong>Tools<\/strong> menu, point to <strong>Formula Auditing<\/strong>, and then click <strong>Formula Auditing Mode<\/strong>.<\/li>\n<\/ol>\n<\/div>\n<table>\n<tbody>\n<tr>\n<td>\n<div>\n<table id=\"NestedTable1\">\n<tbody>\n<tr>\n<td>\u00a0<\/td>\n<\/tr>\n<tr>\n<th><strong>1<\/strong><\/th>\n<\/tr>\n<tr>\n<th><strong>2<\/strong><\/th>\n<\/tr>\n<tr>\n<th><strong>3<\/strong><\/th>\n<\/tr>\n<tr>\n<th><strong>4<\/strong><\/th>\n<\/tr>\n<tr>\n<th><strong>5<\/strong><\/th>\n<\/tr>\n<tr>\n<th><strong>6<\/strong><\/th>\n<\/tr>\n<tr>\n<th><strong>7<\/strong><\/th>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/td>\n<td>\n<div>\n<table id=\"NestedTable2\">\n<tbody>\n<tr>\n<th><strong>A<\/strong><\/th>\n<th><strong>B<\/strong><\/th>\n<\/tr>\n<tr>\n<td><strong>Data<\/strong><\/td>\n<td><strong>Data<\/strong><\/td>\n<\/tr>\n<tr>\n<td>apples<\/td>\n<td>Yes<\/td>\n<\/tr>\n<tr>\n<td>\u00a0<\/td>\n<td>\u00a0<\/td>\n<\/tr>\n<tr>\n<td>oranges<\/td>\n<td>NO<\/td>\n<\/tr>\n<tr>\n<td>peaches<\/td>\n<td>No<\/td>\n<\/tr>\n<tr>\n<td>\u00a0<\/td>\n<td>\u00a0<\/td>\n<\/tr>\n<tr>\n<td>apples<\/td>\n<td>YeS<\/td>\n<\/tr>\n<tr>\n<td><strong>Formula<\/strong><\/td>\n<td><strong>Description (result)<\/strong><\/td>\n<\/tr>\n<tr>\n<td>=COUNTIF(A2:A7,&#8221;*es&#8221;)<\/td>\n<td>Number of cells ending with the letters &#8220;es&#8221; in the first column above (4)<\/td>\n<\/tr>\n<tr>\n<td>=COUNTIF(A2:A7,&#8221;?????es&#8221;)<\/td>\n<td>Number of cells ending with the letters &#8220;les&#8221; and having exactly 7 letters in the first column above (2)<\/td>\n<\/tr>\n<tr>\n<td>=COUNTIF(A2:A7,&#8221;*&#8221;)<\/td>\n<td>Number of cells containing text in the first column above (4)<\/td>\n<\/tr>\n<tr>\n<td>=COUNTIF(A2:A7,&#8221;&lt;&gt;&#8221;&amp;&#8221;*&#8221;)<\/td>\n<td>Number of cells not containing text in the first column above (2)<\/td>\n<\/tr>\n<tr>\n<td>=COUNTIF(B2:B7,&#8221;No&#8221;) \/ ROWS(B2:B7)<\/td>\n<td>The average number of No votes including blank cells in the second column above formatted as a percentage with no decimal places (33%)<\/td>\n<\/tr>\n<tr>\n<td>=COUNTIF(B2:B7,&#8221;Yes&#8221;) \/ (ROWS(B2:B7) -COUNTIF(B2:B7, &#8220;&lt;&gt;&#8221;&amp;&#8221;*&#8221;))<\/td>\n<td>The average number of Yes votes excluding blank cells in the second column above formatted as a percentage with no decimal places (50%)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u00a0Note\u00a0<\/strong>\u00a0\u00a0 To view the number as a percentage, select the cell and click <strong>Cells<\/strong> on the <strong>Format<\/strong> menu. Click the <strong>Number<\/strong> tab, and then click <strong>Percentage<\/strong> in the <strong>Category<\/strong> box.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Countif Counts the number of cells within a range that meet the given criteria. Syntax COUNTIF(range,criteria) Range\u00a0\u00a0\u00a0\u00a0is the range of cells from which you want to count cells. Criteria\u00a0\u00a0\u00a0\u00a0is the criteria in the form of a number, expression, cell reference, or text that defines which cells will be counted. For example, criteria can be expressed [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[433,568],"class_list":["post-1782","post","type-post","status-publish","format-standard","hentry","category-excel-training","tag-pr","tag-using-the-countif-function-in-excel-2010"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.stl-training.co.uk\/b\/wp-json\/wp\/v2\/posts\/1782","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.stl-training.co.uk\/b\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.stl-training.co.uk\/b\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.stl-training.co.uk\/b\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.stl-training.co.uk\/b\/wp-json\/wp\/v2\/comments?post=1782"}],"version-history":[{"count":2,"href":"https:\/\/www.stl-training.co.uk\/b\/wp-json\/wp\/v2\/posts\/1782\/revisions"}],"predecessor-version":[{"id":7544,"href":"https:\/\/www.stl-training.co.uk\/b\/wp-json\/wp\/v2\/posts\/1782\/revisions\/7544"}],"wp:attachment":[{"href":"https:\/\/www.stl-training.co.uk\/b\/wp-json\/wp\/v2\/media?parent=1782"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.stl-training.co.uk\/b\/wp-json\/wp\/v2\/categories?post=1782"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.stl-training.co.uk\/b\/wp-json\/wp\/v2\/tags?post=1782"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}