{"id":4934,"date":"2020-01-27T12:46:08","date_gmt":"2020-01-27T12:46:08","guid":{"rendered":"http:\/\/officetuts.net\/excel\/?p=4934"},"modified":"2024-03-30T00:03:07","modified_gmt":"2024-03-30T00:03:07","slug":"countifs-vba","status":"publish","type":"post","link":"https:\/\/officetuts.net\/excel\/vba\/countifs-vba\/","title":{"rendered":"Countifs VBA"},"content":{"rendered":"\n

The COUNTIFS<\/strong>\nfunction is a popular function if you want to count values for multiple\nconditions. It can also be used with VBA.<\/p>\n\n\n\n

First, let’s take a look at how it works inside a worksheet.<\/p>\n\n\n\n

\"\"<\/figure>\n\n\n\n

The application counts numbers that are larger than 5, and\nsmaller than 8.<\/p>\n\n\n\n

In our example, there are three such numbers in cells: A1<\/strong>, C1<\/strong>, and G1<\/strong>.<\/p>\n\n\n\n

VBA COUNTIFS<\/h2>\n\n\n\n

You can create a procedure in VBA that will look like this:<\/p>\n\n\n\n

Sub myCountifs()\n    BatchCount = Application.WorksheetFunction.CountIfs(Range(\"A1:G1\"), \">5\", Range(\"A1:G1\"), \"<8\")\n    MsgBox BatchCount\nEnd Sub<\/code><\/pre>\n\n\n\n

If you run this code, it’s going to return the following\nmessage.<\/p>\n\n\n\n

\"\"<\/figure>\n","protected":false},"excerpt":{"rendered":"

The COUNTIFS function is a popular function if you want to count values for multiple conditions. It can also be used with VBA….<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[190],"yoast_head":"\nCountifs VBA<\/title>\n<meta name=\"description\" content=\"Learn how to use the COUNTIFS function in Excel, with multiple condition counts and VBA programming options. Find step-by-step instructions and examples here.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/officetuts.net\/excel\/vba\/countifs-vba\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Countifs VBA\" \/>\n<meta property=\"og:description\" content=\"Learn how to use the COUNTIFS function in Excel, with multiple condition counts and VBA programming options. Find step-by-step instructions and examples here.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/officetuts.net\/excel\/vba\/countifs-vba\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-01-27T12:46:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-30T00:03:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/officetuts.net\/excel\/wp-content\/uploads\/sites\/2\/2020\/01\/countifs-worksheet.png\" \/>\n<meta name=\"author\" content=\"Tomasz Decker\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Tomasz Decker\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/officetuts.net\/excel\/vba\/countifs-vba\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/officetuts.net\/excel\/vba\/countifs-vba\/\"},\"author\":{\"name\":\"Tomasz Decker\",\"@id\":\"https:\/\/officetuts.net\/excel\/#\/schema\/person\/41b0b6996aaa4c4127f86f3d24452d42\"},\"headline\":\"Countifs VBA\",\"datePublished\":\"2020-01-27T12:46:08+00:00\",\"dateModified\":\"2024-03-30T00:03:07+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/officetuts.net\/excel\/vba\/countifs-vba\/\"},\"wordCount\":90,\"publisher\":{\"@id\":\"https:\/\/officetuts.net\/excel\/#\/schema\/person\/41b0b6996aaa4c4127f86f3d24452d42\"},\"image\":{\"@id\":\"https:\/\/officetuts.net\/excel\/vba\/countifs-vba\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/officetuts.net\/excel\/wp-content\/uploads\/sites\/2\/2020\/01\/countifs-worksheet.png\",\"keywords\":[\"pinterest\"],\"articleSection\":[\"vba\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/officetuts.net\/excel\/vba\/countifs-vba\/\",\"url\":\"https:\/\/officetuts.net\/excel\/vba\/countifs-vba\/\",\"name\":\"Countifs VBA\",\"isPartOf\":{\"@id\":\"https:\/\/officetuts.net\/excel\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/officetuts.net\/excel\/vba\/countifs-vba\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/officetuts.net\/excel\/vba\/countifs-vba\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/officetuts.net\/excel\/wp-content\/uploads\/sites\/2\/2020\/01\/countifs-worksheet.png\",\"datePublished\":\"2020-01-27T12:46:08+00:00\",\"dateModified\":\"2024-03-30T00:03:07+00:00\",\"description\":\"Learn how to use the COUNTIFS function in Excel, with multiple condition counts and VBA programming options. Find step-by-step instructions and examples here.\",\"breadcrumb\":{\"@id\":\"https:\/\/officetuts.net\/excel\/vba\/countifs-vba\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/officetuts.net\/excel\/vba\/countifs-vba\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/officetuts.net\/excel\/vba\/countifs-vba\/#primaryimage\",\"url\":\"https:\/\/officetuts.net\/excel\/wp-content\/uploads\/sites\/2\/2020\/01\/countifs-worksheet.png\",\"contentUrl\":\"https:\/\/officetuts.net\/excel\/wp-content\/uploads\/sites\/2\/2020\/01\/countifs-worksheet.png\",\"width\":538,\"height\":120},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/officetuts.net\/excel\/vba\/countifs-vba\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/officetuts.net\/excel\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Countifs VBA\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/officetuts.net\/excel\/#website\",\"url\":\"https:\/\/officetuts.net\/excel\/\",\"name\":\"\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/officetuts.net\/excel\/#\/schema\/person\/41b0b6996aaa4c4127f86f3d24452d42\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/officetuts.net\/excel\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/officetuts.net\/excel\/#\/schema\/person\/41b0b6996aaa4c4127f86f3d24452d42\",\"name\":\"Tomasz Decker\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/officetuts.net\/excel\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/18cbe22837193574870ae40ba56bf712?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/18cbe22837193574870ae40ba56bf712?s=96&d=mm&r=g\",\"caption\":\"Tomasz Decker\"},\"logo\":{\"@id\":\"https:\/\/officetuts.net\/excel\/#\/schema\/person\/image\/\"},\"description\":\"Spreadsheet and Python enthusiast.\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Countifs VBA","description":"Learn how to use the COUNTIFS function in Excel, with multiple condition counts and VBA programming options. Find step-by-step instructions and examples here.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/officetuts.net\/excel\/vba\/countifs-vba\/","og_locale":"en_US","og_type":"article","og_title":"Countifs VBA","og_description":"Learn how to use the COUNTIFS function in Excel, with multiple condition counts and VBA programming options. Find step-by-step instructions and examples here.","og_url":"https:\/\/officetuts.net\/excel\/vba\/countifs-vba\/","article_published_time":"2020-01-27T12:46:08+00:00","article_modified_time":"2024-03-30T00:03:07+00:00","og_image":[{"url":"https:\/\/officetuts.net\/excel\/wp-content\/uploads\/sites\/2\/2020\/01\/countifs-worksheet.png"}],"author":"Tomasz Decker","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Tomasz Decker","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/officetuts.net\/excel\/vba\/countifs-vba\/#article","isPartOf":{"@id":"https:\/\/officetuts.net\/excel\/vba\/countifs-vba\/"},"author":{"name":"Tomasz Decker","@id":"https:\/\/officetuts.net\/excel\/#\/schema\/person\/41b0b6996aaa4c4127f86f3d24452d42"},"headline":"Countifs VBA","datePublished":"2020-01-27T12:46:08+00:00","dateModified":"2024-03-30T00:03:07+00:00","mainEntityOfPage":{"@id":"https:\/\/officetuts.net\/excel\/vba\/countifs-vba\/"},"wordCount":90,"publisher":{"@id":"https:\/\/officetuts.net\/excel\/#\/schema\/person\/41b0b6996aaa4c4127f86f3d24452d42"},"image":{"@id":"https:\/\/officetuts.net\/excel\/vba\/countifs-vba\/#primaryimage"},"thumbnailUrl":"https:\/\/officetuts.net\/excel\/wp-content\/uploads\/sites\/2\/2020\/01\/countifs-worksheet.png","keywords":["pinterest"],"articleSection":["vba"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/officetuts.net\/excel\/vba\/countifs-vba\/","url":"https:\/\/officetuts.net\/excel\/vba\/countifs-vba\/","name":"Countifs VBA","isPartOf":{"@id":"https:\/\/officetuts.net\/excel\/#website"},"primaryImageOfPage":{"@id":"https:\/\/officetuts.net\/excel\/vba\/countifs-vba\/#primaryimage"},"image":{"@id":"https:\/\/officetuts.net\/excel\/vba\/countifs-vba\/#primaryimage"},"thumbnailUrl":"https:\/\/officetuts.net\/excel\/wp-content\/uploads\/sites\/2\/2020\/01\/countifs-worksheet.png","datePublished":"2020-01-27T12:46:08+00:00","dateModified":"2024-03-30T00:03:07+00:00","description":"Learn how to use the COUNTIFS function in Excel, with multiple condition counts and VBA programming options. Find step-by-step instructions and examples here.","breadcrumb":{"@id":"https:\/\/officetuts.net\/excel\/vba\/countifs-vba\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/officetuts.net\/excel\/vba\/countifs-vba\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/officetuts.net\/excel\/vba\/countifs-vba\/#primaryimage","url":"https:\/\/officetuts.net\/excel\/wp-content\/uploads\/sites\/2\/2020\/01\/countifs-worksheet.png","contentUrl":"https:\/\/officetuts.net\/excel\/wp-content\/uploads\/sites\/2\/2020\/01\/countifs-worksheet.png","width":538,"height":120},{"@type":"BreadcrumbList","@id":"https:\/\/officetuts.net\/excel\/vba\/countifs-vba\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/officetuts.net\/excel\/"},{"@type":"ListItem","position":2,"name":"Countifs VBA"}]},{"@type":"WebSite","@id":"https:\/\/officetuts.net\/excel\/#website","url":"https:\/\/officetuts.net\/excel\/","name":"","description":"","publisher":{"@id":"https:\/\/officetuts.net\/excel\/#\/schema\/person\/41b0b6996aaa4c4127f86f3d24452d42"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/officetuts.net\/excel\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/officetuts.net\/excel\/#\/schema\/person\/41b0b6996aaa4c4127f86f3d24452d42","name":"Tomasz Decker","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/officetuts.net\/excel\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/18cbe22837193574870ae40ba56bf712?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/18cbe22837193574870ae40ba56bf712?s=96&d=mm&r=g","caption":"Tomasz Decker"},"logo":{"@id":"https:\/\/officetuts.net\/excel\/#\/schema\/person\/image\/"},"description":"Spreadsheet and Python enthusiast."}]}},"_links":{"self":[{"href":"https:\/\/officetuts.net\/excel\/wp-json\/wp\/v2\/posts\/4934"}],"collection":[{"href":"https:\/\/officetuts.net\/excel\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/officetuts.net\/excel\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/officetuts.net\/excel\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/officetuts.net\/excel\/wp-json\/wp\/v2\/comments?post=4934"}],"version-history":[{"count":2,"href":"https:\/\/officetuts.net\/excel\/wp-json\/wp\/v2\/posts\/4934\/revisions"}],"predecessor-version":[{"id":12936,"href":"https:\/\/officetuts.net\/excel\/wp-json\/wp\/v2\/posts\/4934\/revisions\/12936"}],"wp:attachment":[{"href":"https:\/\/officetuts.net\/excel\/wp-json\/wp\/v2\/media?parent=4934"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/officetuts.net\/excel\/wp-json\/wp\/v2\/categories?post=4934"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/officetuts.net\/excel\/wp-json\/wp\/v2\/tags?post=4934"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}