{"id":4347,"date":"2023-07-11T20:09:33","date_gmt":"2023-07-11T20:09:33","guid":{"rendered":"https:\/\/statorials.org\/nl\/vba-telling-uniek\/"},"modified":"2023-07-11T20:09:33","modified_gmt":"2023-07-11T20:09:33","slug":"vba-telling-uniek","status":"publish","type":"post","link":"https:\/\/statorials.org\/nl\/vba-telling-uniek\/","title":{"rendered":"Hoe u unieke waarden binnen bereik kunt tellen met vba"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">U kunt de volgende basissyntaxis gebruiken om het aantal unieke waarden in een bereik te tellen met behulp van VBA:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #0000ff;\"><span style=\"color: #000000;\"><span style=\"color: #0000ff;\">SubCountUnique<\/span> ()\n    <span style=\"color: #0000ff;\">Dim<\/span> Rng <span style=\"color: #0000ff;\">As<\/span> Range, List <span style=\"color: #0000ff;\">As<\/span> Object, UniqueCount <span style=\"color: #0000ff;\">As<\/span> Long\n    <span style=\"color: #0000ff;\">Set<\/span> List = CreateObject(\" <span style=\"color: #ff0000;\">Scripting.Dictionary<\/span> \")\n    \n    <span style=\"color: #008000;\">'count unique values in range A2:A11<\/span>\n    <span style=\"color: #0000ff;\">For<\/span> <span style=\"color: #0000ff;\">Each<\/span> Rng <span style=\"color: #0000ff;\">In<\/span> Range(\" <span style=\"color: #ff0000;\">A2:A11<\/span> \")\n      <span style=\"color: #0000ff;\">If Not<\/span> List.Exists(Rng.Value) <span style=\"color: #0000ff;\">Then<\/span> List.Add Rng.Value, Nothing\n    <span style=\"color: #0000ff;\">Next<\/span>\n    \n<span style=\"color: #008000;\">'store unique count\n<\/span>UniqueCount = List.Count\n    \n    ' <span style=\"color: #008000;\">display unique count<\/span>\n    MsgBox \" <span style=\"color: #ff0000;\">Count of Unique Values:<\/span> \" &amp; UniqueCount<\/span>\n\nEnd Sub\n<\/span><\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Dit specifieke voorbeeld telt het aantal unieke waarden in het bereik <strong>A2:A11<\/strong> en geeft vervolgens de telling weer in een berichtvenster.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Het volgende voorbeeld laat zien hoe u deze syntaxis in de praktijk kunt gebruiken.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Voorbeeld: Tel unieke waarden binnen bereik met behulp van VBA<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Stel dat we de volgende lijst met basketbalteamnamen in Excel hebben:<\/span> <\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-34139 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/vbaunique1.jpg\" alt=\"\" width=\"501\" height=\"409\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\">Stel dat we het aantal unieke teamnamen in het bereik <strong>A2:A11<\/strong> willen tellen.<\/span><\/p>\n<p> <span style=\"color: #000000;\">We kunnen hiervoor de volgende macro maken:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #0000ff;\"><span style=\"color: #000000;\">SubCountUnique()<\/span>\n<span style=\"color: #000000;\"><span style=\"color: #0000ff;\">Dim<\/span> Rng <span style=\"color: #0000ff;\">As<\/span> Range, List <span style=\"color: #0000ff;\">As<\/span> Object, UniqueCount <span style=\"color: #0000ff;\">As<\/span> Long\n    <span style=\"color: #0000ff;\">Set<\/span> List = CreateObject(\" <span style=\"color: #ff0000;\">Scripting.Dictionary<\/span> \")<\/span>\n    \n    <span style=\"color: #008000;\">'count unique values in range A2:A11<\/span>\n<span style=\"color: #000000;\"><span style=\"color: #0000ff;\">For Each<\/span> Rng <span style=\"color: #0000ff;\">In<\/span> Range(\" <span style=\"color: #ff0000;\">A2:A11<\/span> \")\n      <span style=\"color: #0000ff;\">If Not<\/span> List.Exists(Rng.Value) <span style=\"color: #0000ff;\">Then<\/span> List.Add Rng.Value, Nothing\n    <span style=\"color: #0000ff;\">Next<\/span>\n    \n    <span style=\"color: #008000;\">'store unique count<\/span>\n    UniqueCount = List.Count\n    \n    <span style=\"color: #008000;\">'display unique count<\/span>\n    MsgBox \" <span style=\"color: #ff0000;\">Count of Unique Values:<\/span> \" &amp; UniqueCount<\/span>\n\nEnd Sub<\/span><\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Wanneer we deze macro uitvoeren, ontvangen we de volgende uitvoer:<\/span> <\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-34140\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/vbaunique2.jpg\" alt=\"E\u00e9n VBA-nummer\" width=\"485\" height=\"430\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\">Het berichtvenster vertelt ons dat er <strong>5<\/strong> unieke teamnamen zijn.<\/span><\/p>\n<p> <span style=\"color: #000000;\">We kunnen verifi\u00ebren dat dit juist is door elk van de unieke teamnamen handmatig te identificeren:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\">Mav<\/span><\/li>\n<li> <span style=\"color: #000000;\">Warmte<\/span><\/li>\n<li> <span style=\"color: #000000;\">Netten<\/span><\/li>\n<li> <span style=\"color: #000000;\">Strijders<\/span><\/li>\n<li> <span style=\"color: #000000;\">koningen<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Er zijn namelijk 5 unieke teamnamen.<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Opmerking<\/strong> : om het aantal unieke waarden in een ander bereik te tellen, vervangt u eenvoudigweg <strong>A2:A11<\/strong> in de <strong>For Each-<\/strong> lus door een ander bereik.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Aanvullende bronnen<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">In de volgende tutorials wordt uitgelegd hoe u andere veelvoorkomende taken in VBA kunt uitvoeren:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/nl\/vba-telt-cellen-met-specifieke-tekst\/\" target=\"_blank\" rel=\"noopener\">VBA: cellen tellen met specifieke tekst<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/vba-telt-rijen-binnen-bereik\/\" target=\"_blank\" rel=\"noopener\">VBA: het aantal rijen binnen bereik tellen<\/a><br \/> VBA: Hoe COUNTIF- en COUNTIFS-functies te schrijven<\/p>\n","protected":false},"excerpt":{"rendered":"<p>U kunt de volgende basissyntaxis gebruiken om het aantal unieke waarden in een bereik te tellen met behulp van VBA: SubCountUnique () Dim Rng As Range, List As Object, UniqueCount As Long Set List = CreateObject(&#8220; Scripting.Dictionary &#8222;) &#8218;count unique values in range A2:A11 For Each Rng In Range(&#8220; A2:A11 &#8222;) If Not List.Exists(Rng.Value) Then [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-4347","post","type-post","status-publish","format-standard","hentry","category-gids"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Hoe u unieke waarden in een bereik kunt tellen met VBA - Statorials<\/title>\n<meta name=\"description\" content=\"In deze tutorial wordt met een voorbeeld uitgelegd hoe je het aantal unieke waarden in een bereik kunt tellen met behulp van VBA.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/statorials.org\/nl\/vba-telling-uniek\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hoe u unieke waarden in een bereik kunt tellen met VBA - Statorials\" \/>\n<meta property=\"og:description\" content=\"In deze tutorial wordt met een voorbeeld uitgelegd hoe je het aantal unieke waarden in een bereik kunt tellen met behulp van VBA.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/nl\/vba-telling-uniek\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-11T20:09:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/vbaunique1.jpg\" \/>\n<meta name=\"author\" content=\"Dr.benjamin anderson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Verfasst von\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dr.benjamin anderson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Gesch\u00e4tzte Lesezeit\" \/>\n\t<meta name=\"twitter:data2\" content=\"2\u00a0Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/nl\/vba-telling-uniek\/\",\"url\":\"https:\/\/statorials.org\/nl\/vba-telling-uniek\/\",\"name\":\"Hoe u unieke waarden in een bereik kunt tellen met VBA - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/nl\/#website\"},\"datePublished\":\"2023-07-11T20:09:33+00:00\",\"dateModified\":\"2023-07-11T20:09:33+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\"},\"description\":\"In deze tutorial wordt met een voorbeeld uitgelegd hoe je het aantal unieke waarden in een bereik kunt tellen met behulp van VBA.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/nl\/vba-telling-uniek\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/nl\/vba-telling-uniek\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/nl\/vba-telling-uniek\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Thuis\",\"item\":\"https:\/\/statorials.org\/nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hoe u unieke waarden binnen bereik kunt tellen met vba\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/nl\/#website\",\"url\":\"https:\/\/statorials.org\/nl\/\",\"name\":\"Statorials\",\"description\":\"Uw gids voor statistische competentie\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/nl\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"de\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\",\"name\":\"Dr.benjamin anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"de\",\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"caption\":\"Dr.benjamin anderson\"},\"description\":\"Ik ben Benjamin, een gepensioneerde hoogleraar statistiek die nu een toegewijde Statorials-lesgever is. Ik heb uitgebreide ervaring en expertise op het gebied van statistiek en ik ben vastbesloten om mijn kennis te delen met studenten via Statorials. Lees verder\",\"sameAs\":[\"http:\/\/statorials.org\/nl\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Hoe u unieke waarden in een bereik kunt tellen met VBA - Statorials","description":"In deze tutorial wordt met een voorbeeld uitgelegd hoe je het aantal unieke waarden in een bereik kunt tellen met behulp van VBA.","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:\/\/statorials.org\/nl\/vba-telling-uniek\/","og_locale":"de_DE","og_type":"article","og_title":"Hoe u unieke waarden in een bereik kunt tellen met VBA - Statorials","og_description":"In deze tutorial wordt met een voorbeeld uitgelegd hoe je het aantal unieke waarden in een bereik kunt tellen met behulp van VBA.","og_url":"https:\/\/statorials.org\/nl\/vba-telling-uniek\/","og_site_name":"Statorials","article_published_time":"2023-07-11T20:09:33+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/vbaunique1.jpg"}],"author":"Dr.benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Verfasst von":"Dr.benjamin anderson","Gesch\u00e4tzte Lesezeit":"2\u00a0Minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/nl\/vba-telling-uniek\/","url":"https:\/\/statorials.org\/nl\/vba-telling-uniek\/","name":"Hoe u unieke waarden in een bereik kunt tellen met VBA - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/nl\/#website"},"datePublished":"2023-07-11T20:09:33+00:00","dateModified":"2023-07-11T20:09:33+00:00","author":{"@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219"},"description":"In deze tutorial wordt met een voorbeeld uitgelegd hoe je het aantal unieke waarden in een bereik kunt tellen met behulp van VBA.","breadcrumb":{"@id":"https:\/\/statorials.org\/nl\/vba-telling-uniek\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/nl\/vba-telling-uniek\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/nl\/vba-telling-uniek\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Thuis","item":"https:\/\/statorials.org\/nl\/"},{"@type":"ListItem","position":2,"name":"Hoe u unieke waarden binnen bereik kunt tellen met vba"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/nl\/#website","url":"https:\/\/statorials.org\/nl\/","name":"Statorials","description":"Uw gids voor statistische competentie","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/nl\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"de"},{"@type":"Person","@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219","name":"Dr.benjamin anderson","image":{"@type":"ImageObject","inLanguage":"de","@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/image\/","url":"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","contentUrl":"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","caption":"Dr.benjamin anderson"},"description":"Ik ben Benjamin, een gepensioneerde hoogleraar statistiek die nu een toegewijde Statorials-lesgever is. Ik heb uitgebreide ervaring en expertise op het gebied van statistiek en ik ben vastbesloten om mijn kennis te delen met studenten via Statorials. Lees verder","sameAs":["http:\/\/statorials.org\/nl"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/4347","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/comments?post=4347"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/4347\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/media?parent=4347"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/categories?post=4347"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/tags?post=4347"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}