{"id":2129,"date":"2023-09-30T04:50:34","date_gmt":"2023-09-30T04:50:34","guid":{"rendered":"https:\/\/exceladvisor.org\/nl\/als-of\/"},"modified":"2023-12-06T05:48:35","modified_gmt":"2023-12-06T05:48:35","slug":"als-of","status":"publish","type":"page","link":"https:\/\/exceladvisor.org\/nl\/als-of\/","title":{"rendered":"Hoe gebruik ik if met or in vba?"},"content":{"rendered":"<div class=\"excel-voor-de-inhoud\" id=\"excel-2561163112\"><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>OR-<\/strong> operator gebruiken met de <a href=\"https:\/\/exceladvisor.org\/nl\/als-2\/\">VBA IF-instructie<\/a> om meerdere voorwaarden te testen. Wanneer u het gebruikt, kunt u twee of meer voorwaarden tegelijkertijd testen en <strong>wordt true geretourneerd als een van deze voorwaarden waar is<\/strong> . Maar als alle voorwaarden alleen onwaar zijn, wordt in het resultaat onwaar geretourneerd.<\/p><h2 class=\"wp-block-heading\"> OR gebruiken met IF<\/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 trefwoord OR 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-57529\" src=\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-vba-si-ou-condition.png\" sizes=\"auto, \" srcset=\"\" alt=\"vba-als-of-voorwaarde\" width=\"728\" height=\"142\"><\/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() 'two conditions to test using OR If 1 = 1 Or 2 &lt; 1 Then MsgBox \"One of the conditions is true.\" Else MsgBox \"None 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-57530\" src=\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/2-specifie-deux-conditions.png\" sizes=\"auto, \" srcset=\"\" alt=\"\" width=\"581\" height=\"488\"><\/figure><\/div><p> Als je naar het bovenstaande voorbeeld kijkt, hebben we twee voorwaarden gespecificeerd, \u00e9\u00e9n als (1 = 1) en de tweede is (2 &lt; 1), en hier is alleen de eerste voorwaarde waar, en zelfs als deze de coderegel uitvoert die we opgegeven als het resultaat waar is. <\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-57531\" src=\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/3-la-premiere-condition-est-vraie.png\" sizes=\"auto, \" srcset=\"\" alt=\"\" width=\"242\" height=\"192\"><\/figure><\/div><p> Laten we nu eens kijken of beide voorwaarden onwaar zijn. Laat me hier een andere code gebruiken. <\/p><pre class=\"wp-block-code\"> <code class=\"language-visual-basic\" lang=\"visual-basic\">Sub myMacro() 'two conditions to test using OR If 1 = 2 Or 2 &lt; 1 Then MsgBox \"One of the conditions is true.\" Else MsgBox \"None 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-57532\" src=\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/4-les-deux-conditions-sont-fausses.png\" sizes=\"auto, \" srcset=\"\" alt=\"\" width=\"546\" height=\"475\"><\/figure><\/div><p> In de bovenstaande code zijn beide voorwaarden false, en wanneer u <a href=\"https:\/\/exceladvisor.org\/nl\/voer-een-macro-uit-2\/\">deze code 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-57533\" src=\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/5-specifie-si-le-resultat-est-faux.png\" sizes=\"auto, \" srcset=\"\" alt=\"\" width=\"233\" height=\"172\"><\/figure><\/div><h2 class=\"wp-block-heading\"> Meerdere voorwaarden met ALS OF<\/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 myMacro() 'three conditions to test using OR If 1 = 1 And 2 &gt; 1 And 1 - 1 = 0 Then MsgBox \"one of the conditions is true.\" Else MsgBox \"none 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-57534\" src=\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/6-conditions-multiples-avec-if-ou.png\" sizes=\"auto, \" srcset=\"\" alt=\"\" width=\"555\" height=\"472\"><\/figure><\/div><p> We hebben nu drie voorwaarden om te testen en we hebben de OR na de tweede voorwaarde gebruikt om de derde voorwaarde te specificeren. Zoals je hierboven hebt geleerd, moet een van de voorwaarden waar zijn als je OR gebruikt, waar zijn in het resultaat. 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-57535\" src=\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/7-specifie-pour-le-vrai-2.png\" sizes=\"auto, \" srcset=\"\" alt=\"\" width=\"225\" height=\"178\"><\/figure><\/div><p> En als alle voorwaarden onwaar zijn, zoals u deed in de volgende code, retourneert het onwaar. <\/p><pre class=\"wp-block-code\"> <code class=\"language-visual-basic\" lang=\"visual-basic\">Sub myMacro() 'three conditions to test using OR If 1 &lt; 1 And 2 &lt; 1 And 1 + 1 = 0 Then MsgBox \"one of the conditions is true.\" Else MsgBox \"none 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-57536\" src=\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/8-toutes-les-conditions-sont-fausses.png\" sizes=\"auto, \" srcset=\"\" alt=\"\" width=\"247\" height=\"182\"><\/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\/als-en\/\">VBA ALS En<\/a><\/li><li> <a href=\"https:\/\/exceladvisor.org\/nl\/anders\/\">VBA ALS NIET<\/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-2129","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 OR in VBA Excel? (Tutorial 2023)<\/title>\n<meta name=\"description\" content=\"Met VBA OR kunt u meerdere voorwaarden tegelijk testen. Het retourneert waar als een van deze voorwaarden waar is.\" \/>\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-of\/\" \/>\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 OR in VBA Excel? (Tutorial 2023)\" \/>\n<meta property=\"og:description\" content=\"Met VBA OR kunt u meerdere voorwaarden tegelijk testen. Het retourneert waar als een van deze voorwaarden waar is.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/exceladvisor.org\/nl\/als-of\/\" \/>\n<meta property=\"og:site_name\" content=\"Excel Advisor\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-06T05:48:35+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-vba-si-ou-condition.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-of\/\",\"url\":\"https:\/\/exceladvisor.org\/nl\/als-of\/\",\"name\":\"Hoe gebruik ik IF met OR in VBA Excel? (Tutorial 2023)\",\"isPartOf\":{\"@id\":\"https:\/\/exceladvisor.org\/nl\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/exceladvisor.org\/nl\/als-of\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/exceladvisor.org\/nl\/als-of\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-vba-si-ou-condition.png\",\"datePublished\":\"2023-09-30T04:50:34+00:00\",\"dateModified\":\"2023-12-06T05:48:35+00:00\",\"description\":\"Met VBA OR kunt u meerdere voorwaarden tegelijk testen. Het retourneert waar als een van deze voorwaarden waar is.\",\"breadcrumb\":{\"@id\":\"https:\/\/exceladvisor.org\/nl\/als-of\/#breadcrumb\"},\"inLanguage\":\"nl-NL\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/exceladvisor.org\/nl\/als-of\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"nl-NL\",\"@id\":\"https:\/\/exceladvisor.org\/nl\/als-of\/#primaryimage\",\"url\":\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-vba-si-ou-condition.png\",\"contentUrl\":\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-vba-si-ou-condition.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/exceladvisor.org\/nl\/als-of\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Thuis\",\"item\":\"https:\/\/exceladvisor.org\/nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hoe gebruik ik if met or in 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 OR in VBA Excel? (Tutorial 2023)","description":"Met VBA OR kunt u meerdere voorwaarden tegelijk testen. Het retourneert waar als een van deze voorwaarden waar is.","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-of\/","og_locale":"nl_NL","og_type":"article","og_title":"Hoe gebruik ik IF met OR in VBA Excel? (Tutorial 2023)","og_description":"Met VBA OR kunt u meerdere voorwaarden tegelijk testen. Het retourneert waar als een van deze voorwaarden waar is.","og_url":"https:\/\/exceladvisor.org\/nl\/als-of\/","og_site_name":"Excel Advisor","article_modified_time":"2023-12-06T05:48:35+00:00","og_image":[{"url":"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-vba-si-ou-condition.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-of\/","url":"https:\/\/exceladvisor.org\/nl\/als-of\/","name":"Hoe gebruik ik IF met OR in VBA Excel? (Tutorial 2023)","isPartOf":{"@id":"https:\/\/exceladvisor.org\/nl\/#website"},"primaryImageOfPage":{"@id":"https:\/\/exceladvisor.org\/nl\/als-of\/#primaryimage"},"image":{"@id":"https:\/\/exceladvisor.org\/nl\/als-of\/#primaryimage"},"thumbnailUrl":"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-vba-si-ou-condition.png","datePublished":"2023-09-30T04:50:34+00:00","dateModified":"2023-12-06T05:48:35+00:00","description":"Met VBA OR kunt u meerdere voorwaarden tegelijk testen. Het retourneert waar als een van deze voorwaarden waar is.","breadcrumb":{"@id":"https:\/\/exceladvisor.org\/nl\/als-of\/#breadcrumb"},"inLanguage":"nl-NL","potentialAction":[{"@type":"ReadAction","target":["https:\/\/exceladvisor.org\/nl\/als-of\/"]}]},{"@type":"ImageObject","inLanguage":"nl-NL","@id":"https:\/\/exceladvisor.org\/nl\/als-of\/#primaryimage","url":"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-vba-si-ou-condition.png","contentUrl":"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-vba-si-ou-condition.png"},{"@type":"BreadcrumbList","@id":"https:\/\/exceladvisor.org\/nl\/als-of\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Thuis","item":"https:\/\/exceladvisor.org\/nl\/"},{"@type":"ListItem","position":2,"name":"Hoe gebruik ik if met or in 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\/2129","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=2129"}],"version-history":[{"count":1,"href":"https:\/\/exceladvisor.org\/nl\/wp-json\/wp\/v2\/pages\/2129\/revisions"}],"predecessor-version":[{"id":2544,"href":"https:\/\/exceladvisor.org\/nl\/wp-json\/wp\/v2\/pages\/2129\/revisions\/2544"}],"wp:attachment":[{"href":"https:\/\/exceladvisor.org\/nl\/wp-json\/wp\/v2\/media?parent=2129"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}