{"id":2141,"date":"2023-09-29T01:09:10","date_gmt":"2023-09-29T01:09:10","guid":{"rendered":"https:\/\/exceladvisor.org\/nl\/ga-naar-1\/"},"modified":"2023-12-06T05:57:10","modified_gmt":"2023-12-06T05:57:10","slug":"ga-naar-1","status":"publish","type":"page","link":"https:\/\/exceladvisor.org\/nl\/ga-naar-1\/","title":{"rendered":"Hoe de goto-instructie in vba-code te gebruiken?"},"content":{"rendered":"<div class=\"excel-voor-de-inhoud\" id=\"excel-655744993\"><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>De VBA GoTo-instructie helpt de code-uitvoering naar een specifieke regel in de procedure te navigeren. Simpel gezegd springt VBA met de goto-instructie naar een bepaalde regel die u hebt opgegeven. Als u bijvoorbeeld hebt opgegeven om naar de tweede regel te springen, springt go naar die regel.<\/p><h2 class=\"wp-block-heading\"> Hoe de VBA GoTo-instructie in code te gebruiken<\/h2><ol type=\"1\"><li> Eerst moet je de goto-instructie gebruiken.<\/li><li> Daarna moet je defini\u00ebren waar je wilt dat VBA vanaf goto gaat.<\/li><li> Maak vervolgens de tag aan om deze plaats in de procedure aan te maken.<\/li><li> Voeg aan het einde de coderegel(s) toe die u wilt uitvoeren. <\/li><\/ol><div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-59662\" src=\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-vba-aller-a-linstruction-dans-le-code.png\" sizes=\"auto, \" srcset=\"\" alt=\"vba-go-to-statement-in-code\" width=\"593\" height=\"446\"><\/figure><\/div><pre class=\"wp-block-code\"> <code class=\"language-visual-basic\" lang=\"visual-basic\">Sub vba_goto() GoTo <strong>Last<\/strong> <strong>Range<\/strong> (\"A1\"). <strong>Select<\/strong> <strong>Last<\/strong> : <strong>Range<\/strong> (\"A12\"). <strong>Select<\/strong> <strong>End<\/strong> Sub<\/code><\/pre><h2 class=\"wp-block-heading\"> Ga naar om een code te herhalen<\/h2><p> U kunt ook de instructie go to gebruiken om code te herhalen met behulp van een reeks voorwaarden.<\/p><pre class=\"wp-block-code\"> <code class=\"language-visual-basic\" lang=\"visual-basic\"><strong>Sub<\/strong> goto_repeat() <strong>Dim<\/strong> iMessage As String Question:    iMessage = InputBox(\"what's the day today?\") <strong>If<\/strong> iMessage &lt;&gt; \"tuesday\" <strong>Then<\/strong>    MsgBox (\"wrong answer, try again.\") <strong>GoTo<\/strong> Question <strong>Else<\/strong>    MsgBox (\"that's the right answer.\") <strong>End<\/strong> <strong>If<\/strong> <strong>End<\/strong> <strong>Sub<\/strong><\/code><\/pre><p> Wanneer u de bovenstaande code uitvoert, wordt u om de naam van de dag gevraagd en als u iets anders dan &#8220;dinsdag&#8221; invoert, wordt de vraag herhaald. Als je naar de code kijkt, kun je zien dat we de goto-instructie en de <a href=\"https:\/\/exceladvisor.org\/nl\/als-2\/\">if-instructie<\/a> moeten gebruiken.<\/p><p> Wanneer de gebruiker nu iets anders invoert dan het juiste antwoord, dwingt de goto-instructie VBA om de code te herhalen. (maar wanneer je dit soort codes gebruikt, moet je heel voorzichtig zijn, omdat er een eindeloze lus kan ontstaan.<\/p><h2 class=\"wp-block-heading\"> VBA Ga naar einde<\/h2><p> Je kunt een sub ook afsluiten met behulp van de goto-instructie. <\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-59664\" src=\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/2-vba-aller-a-la-fin.png\" sizes=\"auto, \" srcset=\"\" alt=\"vba-go om te eindigen\" width=\"461\" height=\"198\"><\/figure><\/div><p> In de bovenstaande code hebben we de tag &#8220;last&#8221; gebruikt vlak voor de end-instructie en wanneer VBA de GoTo-instructie bereikt, springt VBA naar de &#8220;Last&#8221; aan het einde van de procedure.<\/p><h2 class=\"wp-block-heading\"> GoTo-instructie om naar een regel in een andere subroutine te gaan<\/h2><p> Nou, naar de statement gaan is best handig om VBA van de ene plaats naar de andere te laten springen, maar het is niet mogelijk om het naar een andere procedure in de <a href=\"https:\/\/exceladvisor.org\/nl\/module\/\">module<\/a> te laten springen.<\/p><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\/lussen\/\">VBA-loops (beginner tot gevorderd)<\/a><\/li><li> <a href=\"https:\/\/exceladvisor.org\/nl\/selecteer-de-zaak\/\">VBA Selecteer geval<\/a><\/li><li> <a href=\"https:\/\/exceladvisor.org\/nl\/even-doen\/\">Excel VBA Do While Loop en (Do Loop While) &#8211; Een gids<\/a><\/li><li> <a href=\"https:\/\/exceladvisor.org\/nl\/lus-bladeren\/\">Loop door alle bladen met VBA in Excel<\/a><\/li><li> <a href=\"https:\/\/exceladvisor.org\/nl\/loop-door-het-bereik\/\">Loop over een bereik met behulp van VBA (Kolommen, Rij en UsedRange)<\/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-2141","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>\u25b7 Hoe gebruik ik de GoTo-instructie in VBA-code?<\/title>\n<meta name=\"description\" content=\"In deze zelfstudie leert u hoe u de GoTo-instructie in VBA-code gebruikt om naar een bepaalde regel in de code te navigeren.\" \/>\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\/ga-naar-1\/\" \/>\n<meta property=\"og:locale\" content=\"nl_NL\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u25b7 Hoe gebruik ik de GoTo-instructie in VBA-code?\" \/>\n<meta property=\"og:description\" content=\"In deze zelfstudie leert u hoe u de GoTo-instructie in VBA-code gebruikt om naar een bepaalde regel in de code te navigeren.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/exceladvisor.org\/nl\/ga-naar-1\/\" \/>\n<meta property=\"og:site_name\" content=\"Excel Advisor\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-06T05:57:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-vba-aller-a-linstruction-dans-le-code.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\/ga-naar-1\/\",\"url\":\"https:\/\/exceladvisor.org\/nl\/ga-naar-1\/\",\"name\":\"\u25b7 Hoe gebruik ik de GoTo-instructie in VBA-code?\",\"isPartOf\":{\"@id\":\"https:\/\/exceladvisor.org\/nl\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/exceladvisor.org\/nl\/ga-naar-1\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/exceladvisor.org\/nl\/ga-naar-1\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-vba-aller-a-linstruction-dans-le-code.png\",\"datePublished\":\"2023-09-29T01:09:10+00:00\",\"dateModified\":\"2023-12-06T05:57:10+00:00\",\"description\":\"In deze zelfstudie leert u hoe u de GoTo-instructie in VBA-code gebruikt om naar een bepaalde regel in de code te navigeren.\",\"breadcrumb\":{\"@id\":\"https:\/\/exceladvisor.org\/nl\/ga-naar-1\/#breadcrumb\"},\"inLanguage\":\"nl-NL\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/exceladvisor.org\/nl\/ga-naar-1\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"nl-NL\",\"@id\":\"https:\/\/exceladvisor.org\/nl\/ga-naar-1\/#primaryimage\",\"url\":\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-vba-aller-a-linstruction-dans-le-code.png\",\"contentUrl\":\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-vba-aller-a-linstruction-dans-le-code.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/exceladvisor.org\/nl\/ga-naar-1\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Thuis\",\"item\":\"https:\/\/exceladvisor.org\/nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hoe de goto-instructie in vba-code te gebruiken?\"}]},{\"@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":"\u25b7 Hoe gebruik ik de GoTo-instructie in VBA-code?","description":"In deze zelfstudie leert u hoe u de GoTo-instructie in VBA-code gebruikt om naar een bepaalde regel in de code te navigeren.","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\/ga-naar-1\/","og_locale":"nl_NL","og_type":"article","og_title":"\u25b7 Hoe gebruik ik de GoTo-instructie in VBA-code?","og_description":"In deze zelfstudie leert u hoe u de GoTo-instructie in VBA-code gebruikt om naar een bepaalde regel in de code te navigeren.","og_url":"https:\/\/exceladvisor.org\/nl\/ga-naar-1\/","og_site_name":"Excel Advisor","article_modified_time":"2023-12-06T05:57:10+00:00","og_image":[{"url":"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-vba-aller-a-linstruction-dans-le-code.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\/ga-naar-1\/","url":"https:\/\/exceladvisor.org\/nl\/ga-naar-1\/","name":"\u25b7 Hoe gebruik ik de GoTo-instructie in VBA-code?","isPartOf":{"@id":"https:\/\/exceladvisor.org\/nl\/#website"},"primaryImageOfPage":{"@id":"https:\/\/exceladvisor.org\/nl\/ga-naar-1\/#primaryimage"},"image":{"@id":"https:\/\/exceladvisor.org\/nl\/ga-naar-1\/#primaryimage"},"thumbnailUrl":"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-vba-aller-a-linstruction-dans-le-code.png","datePublished":"2023-09-29T01:09:10+00:00","dateModified":"2023-12-06T05:57:10+00:00","description":"In deze zelfstudie leert u hoe u de GoTo-instructie in VBA-code gebruikt om naar een bepaalde regel in de code te navigeren.","breadcrumb":{"@id":"https:\/\/exceladvisor.org\/nl\/ga-naar-1\/#breadcrumb"},"inLanguage":"nl-NL","potentialAction":[{"@type":"ReadAction","target":["https:\/\/exceladvisor.org\/nl\/ga-naar-1\/"]}]},{"@type":"ImageObject","inLanguage":"nl-NL","@id":"https:\/\/exceladvisor.org\/nl\/ga-naar-1\/#primaryimage","url":"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-vba-aller-a-linstruction-dans-le-code.png","contentUrl":"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-vba-aller-a-linstruction-dans-le-code.png"},{"@type":"BreadcrumbList","@id":"https:\/\/exceladvisor.org\/nl\/ga-naar-1\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Thuis","item":"https:\/\/exceladvisor.org\/nl\/"},{"@type":"ListItem","position":2,"name":"Hoe de goto-instructie in vba-code te gebruiken?"}]},{"@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\/2141","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=2141"}],"version-history":[{"count":1,"href":"https:\/\/exceladvisor.org\/nl\/wp-json\/wp\/v2\/pages\/2141\/revisions"}],"predecessor-version":[{"id":2364,"href":"https:\/\/exceladvisor.org\/nl\/wp-json\/wp\/v2\/pages\/2141\/revisions\/2364"}],"wp:attachment":[{"href":"https:\/\/exceladvisor.org\/nl\/wp-json\/wp\/v2\/media?parent=2141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}