{"id":53,"date":"2023-11-17T21:05:22","date_gmt":"2023-11-17T21:05:22","guid":{"rendered":"https:\/\/exceladvisor.org\/pt\/mesa-com-correntes\/"},"modified":"2023-12-06T11:36:43","modified_gmt":"2023-12-06T11:36:43","slug":"mesa-com-correntes","status":"publish","type":"page","link":"https:\/\/exceladvisor.org\/pt\/mesa-com-correntes\/","title":{"rendered":"Como criar um array com strings via vba?"},"content":{"rendered":"<div class=\"excel-before-content-2\" id=\"excel-4187020463\"><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><div class=\"excel-before-content\" id=\"excel-4164419010\"><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>No VBA, voc\u00ea pode criar um array com strings onde cada elemento do array armazena uma string que voc\u00ea pode acessar posteriormente ou at\u00e9 mesmo combinar em uma \u00fanica string. Al\u00e9m disso, voc\u00ea tamb\u00e9m pode dividir a string principal em v\u00e1rias substrings (usando um delimitador) e ent\u00e3o armazenar cada uma delas nos elementos do array.<\/p><p> Como disse acima, existem duas maneiras de usar strings em um array, e neste tutorial veremos como escrever c\u00f3digo para ambas.<\/p><h2 class=\"wp-block-heading\"> Matriz VBA com strings<\/h2><pre class=\"wp-block-code\"> <code class=\"language-visual-basic\" lang=\"visual-basic\">Option Base 1 Sub vba_string_array() Dim myArray() As Variant myArray = Array(\"One\", \"Two\", \"Three\") Debug.Print myArray(1) Debug.Print myArray(2) Debug.Print myArray(3) End Sub<\/code><\/pre><ol type=\"1\"><li> Primeiro, declare um array sem o n\u00famero de elementos que deseja armazenar nele.<\/li><li> Em seguida, voc\u00ea precisa usar <a href=\"https:\/\/exceladvisor.org\/pt\/implantar\/\">a fun\u00e7\u00e3o ARRAY do VBA<\/a> para definir o valor que deseja especificar.<\/li><li> Depois disso, especifique todas as strings usando uma v\u00edrgula na fun\u00e7\u00e3o.<\/li><li> No final, voc\u00ea pode acessar todos os canais usando o n\u00famero do item. <\/li><\/ol><div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-57132\" src=\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-tableau-vba-avec-des-chaines-1.png\" sizes=\"auto, \" srcset=\"\" alt=\"vba-array-com-strings-1\" width=\"486\" height=\"561\"><\/figure><\/div><p> Da mesma forma, voc\u00ea tamb\u00e9m pode obter uma sequ\u00eancia de c\u00e9lulas para armazenar na tabela. <\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-57133\" src=\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/2-stocker-un-tableau-1.png\" sizes=\"auto, \" srcset=\"\" alt=\"\" width=\"788\" height=\"562\"><\/figure><\/div><h2 class=\"wp-block-heading\"> String dividida VBA e armazenamento em uma matriz<\/h2><p> Se voc\u00ea deseja uma string com v\u00e1rias substrings, pode dividi-la usando <a href=\"https:\/\/exceladvisor.org\/pt\/dividir\/\">a fun\u00e7\u00e3o SPLIT do VBA<\/a> , que usa um delimitador.<\/p><pre class=\"wp-block-code\"> <code class=\"language-visual-basic\" lang=\"visual-basic\">Option Base 1 Sub vba_string_array() Dim myArray() As String myArray = Split(\"Today is a good day\", \" \") For i = LBound(myArray) To UBound(myArray) Debug.Print myArray(i) Next i End Sub<\/code><\/pre><p> Neste c\u00f3digo voc\u00ea tem uma string que \u00e9 uma frase de cinco palavras. E quando voc\u00ea usa a fun\u00e7\u00e3o split, ela a divide em cinco substrings diferentes e ent\u00e3o voc\u00ea a armazena nos elementos do array.<\/p><p> Depois disso, voc\u00ea tem o <a href=\"https:\/\/exceladvisor.org\/pt\/para-o-circuito\/\">loop for<\/a> que usa os limites <a href=\"https:\/\/exceladvisor.org\/pt\/ubound\/\">superior<\/a> e inferior para fazer o loop do contador e imprimir cada elemento do array na <a href=\"https:\/\/exceladvisor.org\/pt\/impressao-de-depuracao-de-janela-imediata\/\">janela imediata<\/a> .<\/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\/pt\/vba\/\">O que \u00e9 VBA<\/a><h2 class=\"gb-headline gb-headline-665e5f6b gb-headline-text gb-headline-mt-heading\"> Saiba mais sobre <a href=\"https:\/\/exceladvisor.org\/pt\/pinturas\/\">tabelas VBA<\/a> <\/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\/pt\/tamanho-da-matriz\/\">Comprimento da matriz VBA (tamanho)<\/a><\/li><li> <a href=\"https:\/\/exceladvisor.org\/pt\/apague-o-quadro\/\">Matriz limpa VBA<\/a><\/li><li> <a href=\"https:\/\/exceladvisor.org\/pt\/tabela-dinamica\/\">Tabela din\u00e2mica VBA<\/a> <\/li><\/ul><\/div><\/div><div class=\"gb-grid-column gb-grid-column-50067b57\"><div class=\"gb-container gb-container-50067b57\"><ul><li> <a href=\"https:\/\/exceladvisor.org\/pt\/matriz-de-loop-vba\/\">Loop VBA em uma matriz<\/a><\/li><li> <a href=\"https:\/\/exceladvisor.org\/pt\/praia-tem-uma-pintura\/\">Intervalo VBA para um array<\/a><\/li><li> <a href=\"https:\/\/exceladvisor.org\/pt\/tabela-de-classificacao\/\">Tabela de sa\u00edda VBA<\/a><\/li><\/ul><\/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-53","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 Como criar um array com strings via VBA?<\/title>\n<meta name=\"description\" content=\"aqui voc\u00ea aprender\u00e1 como usar strings em um array como elementos e tamb\u00e9m aprender\u00e1 como dividir uma string em sub\" \/>\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\/pt\/mesa-com-correntes\/\" \/>\n<meta property=\"og:locale\" content=\"pt_PT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u25b7 Como criar um array com strings via VBA?\" \/>\n<meta property=\"og:description\" content=\"aqui voc\u00ea aprender\u00e1 como usar strings em um array como elementos e tamb\u00e9m aprender\u00e1 como dividir uma string em sub\" \/>\n<meta property=\"og:url\" content=\"https:\/\/exceladvisor.org\/pt\/mesa-com-correntes\/\" \/>\n<meta property=\"og:site_name\" content=\"Excel Advisor\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-06T11:36:43+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-tableau-vba-avec-des-chaines-1.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Tempo estimado de leitura\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/exceladvisor.org\/pt\/mesa-com-correntes\/\",\"url\":\"https:\/\/exceladvisor.org\/pt\/mesa-com-correntes\/\",\"name\":\"\u25b7 Como criar um array com strings via VBA?\",\"isPartOf\":{\"@id\":\"https:\/\/exceladvisor.org\/pt\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/exceladvisor.org\/pt\/mesa-com-correntes\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/exceladvisor.org\/pt\/mesa-com-correntes\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-tableau-vba-avec-des-chaines-1.png\",\"datePublished\":\"2023-11-17T21:05:22+00:00\",\"dateModified\":\"2023-12-06T11:36:43+00:00\",\"description\":\"aqui voc\u00ea aprender\u00e1 como usar strings em um array como elementos e tamb\u00e9m aprender\u00e1 como dividir uma string em sub\",\"breadcrumb\":{\"@id\":\"https:\/\/exceladvisor.org\/pt\/mesa-com-correntes\/#breadcrumb\"},\"inLanguage\":\"pt-PT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/exceladvisor.org\/pt\/mesa-com-correntes\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-PT\",\"@id\":\"https:\/\/exceladvisor.org\/pt\/mesa-com-correntes\/#primaryimage\",\"url\":\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-tableau-vba-avec-des-chaines-1.png\",\"contentUrl\":\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-tableau-vba-avec-des-chaines-1.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/exceladvisor.org\/pt\/mesa-com-correntes\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Lar\",\"item\":\"https:\/\/exceladvisor.org\/pt\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Como criar um array com strings via vba?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/exceladvisor.org\/pt\/#website\",\"url\":\"https:\/\/exceladvisor.org\/pt\/\",\"name\":\"Excel Advisor\",\"description\":\"O seu guia definitivo para dominar os dados!\",\"publisher\":{\"@id\":\"https:\/\/exceladvisor.org\/pt\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/exceladvisor.org\/pt\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"pt-PT\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/exceladvisor.org\/pt\/#organization\",\"name\":\"Excel Advisor\",\"url\":\"https:\/\/exceladvisor.org\/pt\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-PT\",\"@id\":\"https:\/\/exceladvisor.org\/pt\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/exceladvisor.org\/pt\/wp-content\/uploads\/2023\/12\/exceladvisor.org_.png\",\"contentUrl\":\"https:\/\/exceladvisor.org\/pt\/wp-content\/uploads\/2023\/12\/exceladvisor.org_.png\",\"width\":105,\"height\":36,\"caption\":\"Excel Advisor\"},\"image\":{\"@id\":\"https:\/\/exceladvisor.org\/pt\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u25b7 Como criar um array com strings via VBA?","description":"aqui voc\u00ea aprender\u00e1 como usar strings em um array como elementos e tamb\u00e9m aprender\u00e1 como dividir uma string em sub","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\/pt\/mesa-com-correntes\/","og_locale":"pt_PT","og_type":"article","og_title":"\u25b7 Como criar um array com strings via VBA?","og_description":"aqui voc\u00ea aprender\u00e1 como usar strings em um array como elementos e tamb\u00e9m aprender\u00e1 como dividir uma string em sub","og_url":"https:\/\/exceladvisor.org\/pt\/mesa-com-correntes\/","og_site_name":"Excel Advisor","article_modified_time":"2023-12-06T11:36:43+00:00","og_image":[{"url":"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-tableau-vba-avec-des-chaines-1.png","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Tempo estimado de leitura":"2 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/exceladvisor.org\/pt\/mesa-com-correntes\/","url":"https:\/\/exceladvisor.org\/pt\/mesa-com-correntes\/","name":"\u25b7 Como criar um array com strings via VBA?","isPartOf":{"@id":"https:\/\/exceladvisor.org\/pt\/#website"},"primaryImageOfPage":{"@id":"https:\/\/exceladvisor.org\/pt\/mesa-com-correntes\/#primaryimage"},"image":{"@id":"https:\/\/exceladvisor.org\/pt\/mesa-com-correntes\/#primaryimage"},"thumbnailUrl":"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-tableau-vba-avec-des-chaines-1.png","datePublished":"2023-11-17T21:05:22+00:00","dateModified":"2023-12-06T11:36:43+00:00","description":"aqui voc\u00ea aprender\u00e1 como usar strings em um array como elementos e tamb\u00e9m aprender\u00e1 como dividir uma string em sub","breadcrumb":{"@id":"https:\/\/exceladvisor.org\/pt\/mesa-com-correntes\/#breadcrumb"},"inLanguage":"pt-PT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/exceladvisor.org\/pt\/mesa-com-correntes\/"]}]},{"@type":"ImageObject","inLanguage":"pt-PT","@id":"https:\/\/exceladvisor.org\/pt\/mesa-com-correntes\/#primaryimage","url":"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-tableau-vba-avec-des-chaines-1.png","contentUrl":"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-tableau-vba-avec-des-chaines-1.png"},{"@type":"BreadcrumbList","@id":"https:\/\/exceladvisor.org\/pt\/mesa-com-correntes\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Lar","item":"https:\/\/exceladvisor.org\/pt\/"},{"@type":"ListItem","position":2,"name":"Como criar um array com strings via vba?"}]},{"@type":"WebSite","@id":"https:\/\/exceladvisor.org\/pt\/#website","url":"https:\/\/exceladvisor.org\/pt\/","name":"Excel Advisor","description":"O seu guia definitivo para dominar os dados!","publisher":{"@id":"https:\/\/exceladvisor.org\/pt\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/exceladvisor.org\/pt\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"pt-PT"},{"@type":"Organization","@id":"https:\/\/exceladvisor.org\/pt\/#organization","name":"Excel Advisor","url":"https:\/\/exceladvisor.org\/pt\/","logo":{"@type":"ImageObject","inLanguage":"pt-PT","@id":"https:\/\/exceladvisor.org\/pt\/#\/schema\/logo\/image\/","url":"https:\/\/exceladvisor.org\/pt\/wp-content\/uploads\/2023\/12\/exceladvisor.org_.png","contentUrl":"https:\/\/exceladvisor.org\/pt\/wp-content\/uploads\/2023\/12\/exceladvisor.org_.png","width":105,"height":36,"caption":"Excel Advisor"},"image":{"@id":"https:\/\/exceladvisor.org\/pt\/#\/schema\/logo\/image\/"}}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/exceladvisor.org\/pt\/wp-json\/wp\/v2\/pages\/53","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/exceladvisor.org\/pt\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/exceladvisor.org\/pt\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/exceladvisor.org\/pt\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/exceladvisor.org\/pt\/wp-json\/wp\/v2\/comments?post=53"}],"version-history":[{"count":1,"href":"https:\/\/exceladvisor.org\/pt\/wp-json\/wp\/v2\/pages\/53\/revisions"}],"predecessor-version":[{"id":980,"href":"https:\/\/exceladvisor.org\/pt\/wp-json\/wp\/v2\/pages\/53\/revisions\/980"}],"wp:attachment":[{"href":"https:\/\/exceladvisor.org\/pt\/wp-json\/wp\/v2\/media?parent=53"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}