{"id":2130,"date":"2023-09-30T04:41:34","date_gmt":"2023-09-30T04:41:34","guid":{"rendered":"https:\/\/exceladvisor.org\/nl\/als-en\/"},"modified":"2023-12-06T05:48:34","modified_gmt":"2023-12-06T05:48:34","slug":"als-en","status":"publish","type":"page","link":"https:\/\/exceladvisor.org\/nl\/als-en\/","title":{"rendered":"Hoe gebruik ik if met and in excel vba?"},"content":{"rendered":"<div class=\"excel-voor-de-inhoud\" id=\"excel-3750906408\"><script type=\"text\/javascript\">\r\n\tatOptions = {\r\n\t\t'key' : 'c1158f160081d6540a8409e6925dab94',\r\n\t\t'format' : 'iframe',\r\n\t\t'height' : 250,\r\n\t\t'width' : 300,\r\n\t\t'params' : {}\r\n\t};\r\n<\/script>\r\n<script type=\"text\/javascript\" src=\"\/\/www.highperformanceformat.com\/c1158f160081d6540a8409e6925dab94\/invoke.js\"><\/script><\/div> <p>U kunt de <strong>AND-<\/strong> operator gebruiken met de <a href=\"https:\/\/exceladvisor.org\/nl\/als-2\/\">VBA IF-instructie<\/a> om meerdere voorwaarden te testen, en als u deze gebruikt, kunt u twee voorwaarden tegelijkertijd testen en waar worden als beide voorwaarden waar zijn. En als een van de voorwaarden onwaar is, retourneert deze onwaar in het resultaat.<\/p><h2 class=\"wp-block-heading\"> Combineer ALS EN<\/h2><ol type=\"1\"><li> Begin eerst de IF-instructie met het trefwoord \u201cIF\u201d.<\/li><li> Geef daarna de eerste voorwaarde op die u wilt testen.<\/li><li> Gebruik vervolgens het sleutelwoord AND om de tweede voorwaarde op te geven<\/li><li> Geef aan het einde de tweede voorwaarde op die u wilt testen. <\/li><\/ol><div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-57514\" src=\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-vba-si-instruction.png\" sizes=\"auto, \" srcset=\"\" alt=\"vba-if-instructie\" width=\"819\" height=\"119\"><\/figure><\/div><p> Laten we een voorbeeld bekijken om het beter te begrijpen. <\/p><pre class=\"wp-block-code\"> <code class=\"language-visual-basic\" lang=\"visual-basic\">Sub myMacro() If 1 = 1 And 2 &gt; 1 Then MsgBox \"Both of the conditions are true.\" Else MsgBox \"Maybe one or both of the conditions are true.\" End If End Sub<\/code><\/pre><div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-57515\" src=\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/2-vba-si-exemple-dinstruction.png\" sizes=\"auto, \" srcset=\"\" alt=\"\" width=\"678\" height=\"351\"><\/figure><\/div><p> Als je naar het bovenstaande voorbeeld kijkt, hebben we twee voorwaarden gespecificeerd: \u00e9\u00e9n if (1 = 1) en de tweede is (2 &gt; 1) en hier zijn beide voorwaarden waar, en daarom wordt de coderegel uitgevoerd die we hebben opgegeven als het resultaat is waar. <\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-57516\" src=\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/3-execute-la-ligne-de-code.png\" sizes=\"auto, \" srcset=\"\" alt=\"\" width=\"232\" height=\"173\"><\/figure><\/div><p> Als een van deze twee voorwaarden niet waar is, laat me dan hier een andere code gebruiken. <\/p><pre class=\"wp-block-code\"> <code class=\"language-visual-basic\" lang=\"visual-basic\">Sub myMacro1() If 1 = 1 And 2 &lt; 1 Then MsgBox \"Both of the conditions are true.\" Else MsgBox \"Maybe one or both of the conditions are true.\" End If End Sub<\/code><\/pre><div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-57517\" src=\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/4-deuxieme-condition-est-fausse.png\" sizes=\"auto, \" srcset=\"\" alt=\"\" width=\"655\" height=\"351\"><\/figure><\/div><p> In de bovenstaande code is de tweede voorwaarde false (2 &lt; 1) en wanneer u <a href=\"https:\/\/exceladvisor.org\/nl\/voer-een-macro-uit-2\/\">deze macro uitvoert<\/a> , wordt de coderegel uitgevoerd die we hebben opgegeven als het resultaat false is. <\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-57518\" src=\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/5-le-resultat-est-faux.png\" sizes=\"auto, \" srcset=\"\" alt=\"\" width=\"352\" height=\"192\"><\/figure><\/div><h2 class=\"wp-block-heading\"> Meerdere voorwaarden met ALS EN<\/h2><p> Op dezelfde manier kunt u ook meer dan twee voorwaarden tegelijkertijd testen. Laten we doorgaan met het bovenstaande voorbeeld en er de derde voorwaarde aan toevoegen. <\/p><pre class=\"wp-block-code\"> <code class=\"language-visual-basic\" lang=\"visual-basic\">Sub myMacro2() If 1 = 1 And 2 &gt; 1 And 1 - 1 = 0 Then MsgBox \"All the conditions are true.\" Else MsgBox \"Some conditions are false.\" End If End Sub<\/code><\/pre><div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-57519\" src=\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/6-conditions-multiples-avec-if-et.png\" sizes=\"auto, \" srcset=\"\" alt=\"\" width=\"521\" height=\"374\"><\/figure><\/div><p> We hebben nu drie voorwaarden om te testen en we hebben de EN na de tweede voorwaarde gebruikt om de derde voorwaarde te specificeren. Zoals je hierboven hebt geleerd, moeten bij het gebruik van AND alle voorwaarden waar zijn om waar te worden in het resultaat.<\/p><p> Wanneer u deze code uitvoert, wordt de coderegel uitgevoerd die we voor true hebben opgegeven. <\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-57520\" src=\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/7-specifie-pour-le-vrai.png\" sizes=\"auto, \" srcset=\"\" alt=\"\" width=\"211\" height=\"178\"><\/figure><\/div><p> En als een van de voorwaarden onwaar is, net zoals u deed in de volgende code, retourneert deze onwaar. <\/p><pre class=\"wp-block-code\"> <code class=\"language-visual-basic\" lang=\"visual-basic\">Sub myMacro3() If 1 = 1 And 2 &lt; 1 And 1 + 1 = 0 Then MsgBox \"All the conditions are true.\" Else MsgBox \"Some conditions are false.\" End If End Sub<\/code><\/pre><div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-57521\" src=\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/8-condition-est-fausse.png\" sizes=\"auto, \" srcset=\"\" alt=\"\" width=\"221\" height=\"188\"><\/figure><\/div><div class=\"gb-container gb-container-4db6181c gb-container-mt\"> <a class=\"gb-button gb-button-c5897111 gb-button-text gb-button-mt-button\" href=\"https:\/\/exceladvisor.org\/nl\/vba\/\">Wat is VBA<\/a><h2 class=\"gb-headline gb-headline-665e5f6b gb-headline-text gb-headline-mt-heading\"> Gerelateerde tutorials <\/h2><div class=\"gb-grid-wrapper gb-grid-wrapper-a20baf7c gb-grid-wrapper-mt-grid\"><div class=\"gb-grid-column gb-grid-column-65ddf67e\"><div class=\"gb-container gb-container-65ddf67e\"><ul><li> <a href=\"https:\/\/exceladvisor.org\/nl\/ga-uit-als\/\">VBA Afsluiten IF<\/a><\/li><li> <a href=\"https:\/\/exceladvisor.org\/nl\/als-2\/\">VBA ALS (ALS dan anders)<\/a><\/li><li> <a href=\"https:\/\/exceladvisor.org\/nl\/anders\/\">VBA INDIEN NEE<\/a><\/li><li> <a href=\"https:\/\/exceladvisor.org\/nl\/als-of\/\">VBA ALS OF<\/a><\/li><li> <a href=\"https:\/\/exceladvisor.org\/nl\/nestelen-als\/\">VBA genest IF<\/a> <\/li><\/ul><\/div><\/div><div class=\"gb-grid-column gb-grid-column-50067b57\"><div class=\"gb-container gb-container-50067b57\"><\/div><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"ub_ctt_via":"","footnotes":""},"class_list":["post-2130","page","type-page","status-publish","hentry"],"featured_image_src":null,"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Hoe gebruik ik IF met AND in Excel VBA? Handleiding 2023)<\/title>\n<meta name=\"description\" content=\"U kunt de AND-operator gebruiken met de VBA IF-instructie om meerdere voorwaarden te testen, en als u deze gebruikt, kunt u dat ook doen\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/exceladvisor.org\/nl\/als-en\/\" \/>\n<meta property=\"og:locale\" content=\"nl_NL\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hoe gebruik ik IF met AND in Excel VBA? Handleiding 2023)\" \/>\n<meta property=\"og:description\" content=\"U kunt de AND-operator gebruiken met de VBA IF-instructie om meerdere voorwaarden te testen, en als u deze gebruikt, kunt u dat ook doen\" \/>\n<meta property=\"og:url\" content=\"https:\/\/exceladvisor.org\/nl\/als-en\/\" \/>\n<meta property=\"og:site_name\" content=\"Excel Advisor\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-06T05:48:34+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-vba-si-instruction.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Geschatte leestijd\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/exceladvisor.org\/nl\/als-en\/\",\"url\":\"https:\/\/exceladvisor.org\/nl\/als-en\/\",\"name\":\"Hoe gebruik ik IF met AND in Excel VBA? Handleiding 2023)\",\"isPartOf\":{\"@id\":\"https:\/\/exceladvisor.org\/nl\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/exceladvisor.org\/nl\/als-en\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/exceladvisor.org\/nl\/als-en\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-vba-si-instruction.png\",\"datePublished\":\"2023-09-30T04:41:34+00:00\",\"dateModified\":\"2023-12-06T05:48:34+00:00\",\"description\":\"U kunt de AND-operator gebruiken met de VBA IF-instructie om meerdere voorwaarden te testen, en als u deze gebruikt, kunt u dat ook doen\",\"breadcrumb\":{\"@id\":\"https:\/\/exceladvisor.org\/nl\/als-en\/#breadcrumb\"},\"inLanguage\":\"nl-NL\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/exceladvisor.org\/nl\/als-en\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"nl-NL\",\"@id\":\"https:\/\/exceladvisor.org\/nl\/als-en\/#primaryimage\",\"url\":\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-vba-si-instruction.png\",\"contentUrl\":\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-vba-si-instruction.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/exceladvisor.org\/nl\/als-en\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Thuis\",\"item\":\"https:\/\/exceladvisor.org\/nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hoe gebruik ik if met and in excel vba?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/exceladvisor.org\/nl\/#website\",\"url\":\"https:\/\/exceladvisor.org\/nl\/\",\"name\":\"Excel Advisor\",\"description\":\"Uw gids voor datadominantie\",\"publisher\":{\"@id\":\"https:\/\/exceladvisor.org\/nl\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/exceladvisor.org\/nl\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"nl-NL\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/exceladvisor.org\/nl\/#organization\",\"name\":\"Excel Advisor\",\"url\":\"https:\/\/exceladvisor.org\/nl\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"nl-NL\",\"@id\":\"https:\/\/exceladvisor.org\/nl\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/exceladvisor.org\/nl\/wp-content\/uploads\/2023\/12\/exceladvisor.org_.png\",\"contentUrl\":\"https:\/\/exceladvisor.org\/nl\/wp-content\/uploads\/2023\/12\/exceladvisor.org_.png\",\"width\":105,\"height\":36,\"caption\":\"Excel Advisor\"},\"image\":{\"@id\":\"https:\/\/exceladvisor.org\/nl\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Hoe gebruik ik IF met AND in Excel VBA? Handleiding 2023)","description":"U kunt de AND-operator gebruiken met de VBA IF-instructie om meerdere voorwaarden te testen, en als u deze gebruikt, kunt u dat ook doen","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:\/\/exceladvisor.org\/nl\/als-en\/","og_locale":"nl_NL","og_type":"article","og_title":"Hoe gebruik ik IF met AND in Excel VBA? Handleiding 2023)","og_description":"U kunt de AND-operator gebruiken met de VBA IF-instructie om meerdere voorwaarden te testen, en als u deze gebruikt, kunt u dat ook doen","og_url":"https:\/\/exceladvisor.org\/nl\/als-en\/","og_site_name":"Excel Advisor","article_modified_time":"2023-12-06T05:48:34+00:00","og_image":[{"url":"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-vba-si-instruction.png","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Geschatte leestijd":"2 minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/exceladvisor.org\/nl\/als-en\/","url":"https:\/\/exceladvisor.org\/nl\/als-en\/","name":"Hoe gebruik ik IF met AND in Excel VBA? Handleiding 2023)","isPartOf":{"@id":"https:\/\/exceladvisor.org\/nl\/#website"},"primaryImageOfPage":{"@id":"https:\/\/exceladvisor.org\/nl\/als-en\/#primaryimage"},"image":{"@id":"https:\/\/exceladvisor.org\/nl\/als-en\/#primaryimage"},"thumbnailUrl":"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-vba-si-instruction.png","datePublished":"2023-09-30T04:41:34+00:00","dateModified":"2023-12-06T05:48:34+00:00","description":"U kunt de AND-operator gebruiken met de VBA IF-instructie om meerdere voorwaarden te testen, en als u deze gebruikt, kunt u dat ook doen","breadcrumb":{"@id":"https:\/\/exceladvisor.org\/nl\/als-en\/#breadcrumb"},"inLanguage":"nl-NL","potentialAction":[{"@type":"ReadAction","target":["https:\/\/exceladvisor.org\/nl\/als-en\/"]}]},{"@type":"ImageObject","inLanguage":"nl-NL","@id":"https:\/\/exceladvisor.org\/nl\/als-en\/#primaryimage","url":"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-vba-si-instruction.png","contentUrl":"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-vba-si-instruction.png"},{"@type":"BreadcrumbList","@id":"https:\/\/exceladvisor.org\/nl\/als-en\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Thuis","item":"https:\/\/exceladvisor.org\/nl\/"},{"@type":"ListItem","position":2,"name":"Hoe gebruik ik if met and in excel vba?"}]},{"@type":"WebSite","@id":"https:\/\/exceladvisor.org\/nl\/#website","url":"https:\/\/exceladvisor.org\/nl\/","name":"Excel Advisor","description":"Uw gids voor datadominantie","publisher":{"@id":"https:\/\/exceladvisor.org\/nl\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/exceladvisor.org\/nl\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"nl-NL"},{"@type":"Organization","@id":"https:\/\/exceladvisor.org\/nl\/#organization","name":"Excel Advisor","url":"https:\/\/exceladvisor.org\/nl\/","logo":{"@type":"ImageObject","inLanguage":"nl-NL","@id":"https:\/\/exceladvisor.org\/nl\/#\/schema\/logo\/image\/","url":"https:\/\/exceladvisor.org\/nl\/wp-content\/uploads\/2023\/12\/exceladvisor.org_.png","contentUrl":"https:\/\/exceladvisor.org\/nl\/wp-content\/uploads\/2023\/12\/exceladvisor.org_.png","width":105,"height":36,"caption":"Excel Advisor"},"image":{"@id":"https:\/\/exceladvisor.org\/nl\/#\/schema\/logo\/image\/"}}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/exceladvisor.org\/nl\/wp-json\/wp\/v2\/pages\/2130","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/exceladvisor.org\/nl\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/exceladvisor.org\/nl\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/exceladvisor.org\/nl\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/exceladvisor.org\/nl\/wp-json\/wp\/v2\/comments?post=2130"}],"version-history":[{"count":1,"href":"https:\/\/exceladvisor.org\/nl\/wp-json\/wp\/v2\/pages\/2130\/revisions"}],"predecessor-version":[{"id":2543,"href":"https:\/\/exceladvisor.org\/nl\/wp-json\/wp\/v2\/pages\/2130\/revisions\/2543"}],"wp:attachment":[{"href":"https:\/\/exceladvisor.org\/nl\/wp-json\/wp\/v2\/media?parent=2130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}