{"id":1525,"date":"2023-11-17T21:24:59","date_gmt":"2023-11-17T21:24:59","guid":{"rendered":"https:\/\/exceladvisor.org\/it\/aggiungere-una-nuova-matrice-di-valori\/"},"modified":"2023-12-10T06:20:03","modified_gmt":"2023-12-10T06:20:03","slug":"aggiungere-una-nuova-matrice-di-valori","status":"publish","type":"page","link":"https:\/\/exceladvisor.org\/it\/aggiungere-una-nuova-matrice-di-valori\/","title":{"rendered":"Come aggiungere un nuovo valore a un array tramite vba?"},"content":{"rendered":"<div class=\"excel-prima-del-contenuto\" id=\"excel-3212702743\"><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>Per aggiungere un nuovo valore a un array esistente, \u00e8 necessario disporre di un array dinamico per ridefinire i suoi elementi e, quando lo fai, devi mantenere i valori dei vecchi elementi. Questo ti aiuta ad aggiungere solo il valore al nuovo elemento che definisci e lascia intatto il resto della parte.<\/p><p> Di seguito hai un array in cui hai definito due elementi. Poich\u00e9 si tratta di un array dinamico, \u00e8 disponibile un&#8217;istruzione &#8220;ReDim&#8221; per definire due elementi e quindi aggiungere valori a tali elementi. <\/p><div class=\"wp-block-image is-style-default\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-57215\" src=\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-tableau-dynamique-pour-redefinir-les-elements-1-2.png\" sizes=\"auto, \" srcset=\"\" alt=\"array-dinamico-da-ridefinire-elementi\" width=\"497\" height=\"359\"><\/figure><\/div><p> Aggiungeremo quindi un terzo elemento a questo array.<\/p><h2 class=\"wp-block-heading\"> <strong>Aggiungi un nuovo valore a un array in VBA<\/strong><\/h2><div class=\"wp-block-image is-style-default\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-57216\" src=\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/2-ajouter-une-nouvelle-valeur-a-un-tableau-2.png\" sizes=\"auto, \" srcset=\"\" alt=\"\" width=\"505\" height=\"564\"><\/figure><\/div><ol type=\"1\"><li> Innanzitutto, devi utilizzare l&#8217;istruzione &#8220;ReDim&#8221; con la parola chiave &#8220;Preserve&#8221; per preservare entrambi gli elementi, incluso il nuovo elemento per il quale desideri aggiungere il valore.<\/li><li> Successivamente, devi definire gli elementi che desideri avere nell&#8217;array. Qui devi avere tre elementi, quindi usiamo da 1 a 3 per questo.<\/li><li> Dopodich\u00e9 devi aggiungere valore al terzo elemento che \u00e8 il nuovo elemento che definisci.<\/li><li> Alla fine usa <a href=\"https:\/\/exceladvisor.org\/it\/stampa-immediata-del-debug-della-finestra\/\">debug.print<\/a> per ottenere tutti gli elementi con i nuovi elementi nella finestra immediata.<\/li><\/ol><pre class=\"wp-block-code\"> <code class=\"language-visual-basic\" lang=\"visual-basic\">Option Explicit Option Base 1 Sub vba_array_add_value() Dim myArray() As Variant ReDim myArray(2) myArray(1) = 5 myArray(2) = 10 ReDim Preserve myArray(1 To 3) myArray(3) = 15 Debug.Print myArray(1) Debug.Print myArray(2) Debug.Print myArray(3) End Sub<\/code><\/pre><p> Permettetemi di condividere con voi ancora qualche parola.<\/p><ul><li> Dovresti dichiarare un array come array dinamico all&#8217;inizio se sai che dovrai aggiungere pi\u00f9 valore all&#8217;array nel codice in seguito.<\/li><li> Usando questo metodo puoi aggiungere solo un nuovo elemento alla fine dell&#8217;array.<\/li><\/ul><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\/it\/vba\/\">Cos&#8217;\u00e8 VBA<\/a><h2 class=\"gb-headline gb-headline-665e5f6b gb-headline-text gb-headline-mt-heading\"> Ulteriori informazioni sulle <a href=\"https:\/\/exceladvisor.org\/it\/dipinti\/\">tabelle 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\/it\/dimensione-della-matrice\/\">Lunghezza dell&#8217;array VBA (dimensione)<\/a><\/li><li> <a href=\"https:\/\/exceladvisor.org\/it\/tavolo-con-catene\/\">Array VBA con stringhe<\/a><\/li><li> <a href=\"https:\/\/exceladvisor.org\/it\/cancella-la-lavagna\/\">Cancella matrice VBA<\/a><\/li><li> <a href=\"https:\/\/exceladvisor.org\/it\/tabella-dinamica\/\">Tabella dinamica 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\/it\/array-di-loop-vba\/\">Ciclo VBA in un array<\/a><\/li><li> <a href=\"https:\/\/exceladvisor.org\/it\/matrice-multidimensionale\/\">Array multidimensionale VBA<\/a><\/li><li> <a href=\"https:\/\/exceladvisor.org\/it\/la-spiaggia-ha-un-dipinto\/\">Intervallo VBA in un array<\/a><\/li><li> <a href=\"https:\/\/exceladvisor.org\/it\/tavolo-di-smistamento\/\">Tabella di output 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-1525","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>Come aggiungere un nuovo valore a un array tramite VBA?<\/title>\n<meta name=\"description\" content=\"In questo tutorial imparerai come aggiungere un nuovo valore a un array in VBA. Aggiungi il valore al nuovo oggetto che hai\" \/>\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\/it\/aggiungere-una-nuova-matrice-di-valori\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Come aggiungere un nuovo valore a un array tramite VBA?\" \/>\n<meta property=\"og:description\" content=\"In questo tutorial imparerai come aggiungere un nuovo valore a un array in VBA. Aggiungi il valore al nuovo oggetto che hai\" \/>\n<meta property=\"og:url\" content=\"https:\/\/exceladvisor.org\/it\/aggiungere-una-nuova-matrice-di-valori\/\" \/>\n<meta property=\"og:site_name\" content=\"Excel Advisor\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-10T06:20:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-tableau-dynamique-pour-redefinir-les-elements-1-2.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Tempo di lettura stimato\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minuto\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/exceladvisor.org\/it\/aggiungere-una-nuova-matrice-di-valori\/\",\"url\":\"https:\/\/exceladvisor.org\/it\/aggiungere-una-nuova-matrice-di-valori\/\",\"name\":\"Come aggiungere un nuovo valore a un array tramite VBA?\",\"isPartOf\":{\"@id\":\"https:\/\/exceladvisor.org\/it\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/exceladvisor.org\/it\/aggiungere-una-nuova-matrice-di-valori\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/exceladvisor.org\/it\/aggiungere-una-nuova-matrice-di-valori\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-tableau-dynamique-pour-redefinir-les-elements-1-2.png\",\"datePublished\":\"2023-11-17T21:24:59+00:00\",\"dateModified\":\"2023-12-10T06:20:03+00:00\",\"description\":\"In questo tutorial imparerai come aggiungere un nuovo valore a un array in VBA. Aggiungi il valore al nuovo oggetto che hai\",\"breadcrumb\":{\"@id\":\"https:\/\/exceladvisor.org\/it\/aggiungere-una-nuova-matrice-di-valori\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/exceladvisor.org\/it\/aggiungere-una-nuova-matrice-di-valori\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"it-IT\",\"@id\":\"https:\/\/exceladvisor.org\/it\/aggiungere-una-nuova-matrice-di-valori\/#primaryimage\",\"url\":\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-tableau-dynamique-pour-redefinir-les-elements-1-2.png\",\"contentUrl\":\"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-tableau-dynamique-pour-redefinir-les-elements-1-2.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/exceladvisor.org\/it\/aggiungere-una-nuova-matrice-di-valori\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/exceladvisor.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Come aggiungere un nuovo valore a un array tramite vba?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/exceladvisor.org\/it\/#website\",\"url\":\"https:\/\/exceladvisor.org\/it\/\",\"name\":\"Excel Advisor\",\"description\":\"Tips, Tricks, and Time-Saving Hacks\",\"publisher\":{\"@id\":\"https:\/\/exceladvisor.org\/it\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/exceladvisor.org\/it\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"it-IT\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/exceladvisor.org\/it\/#organization\",\"name\":\"Excel Advisor\",\"url\":\"https:\/\/exceladvisor.org\/it\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"it-IT\",\"@id\":\"https:\/\/exceladvisor.org\/it\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/exceladvisor.org\/it\/wp-content\/uploads\/2023\/12\/exceladvisor.org_.png\",\"contentUrl\":\"https:\/\/exceladvisor.org\/it\/wp-content\/uploads\/2023\/12\/exceladvisor.org_.png\",\"width\":105,\"height\":36,\"caption\":\"Excel Advisor\"},\"image\":{\"@id\":\"https:\/\/exceladvisor.org\/it\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Come aggiungere un nuovo valore a un array tramite VBA?","description":"In questo tutorial imparerai come aggiungere un nuovo valore a un array in VBA. Aggiungi il valore al nuovo oggetto che hai","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\/it\/aggiungere-una-nuova-matrice-di-valori\/","og_locale":"it_IT","og_type":"article","og_title":"Come aggiungere un nuovo valore a un array tramite VBA?","og_description":"In questo tutorial imparerai come aggiungere un nuovo valore a un array in VBA. Aggiungi il valore al nuovo oggetto che hai","og_url":"https:\/\/exceladvisor.org\/it\/aggiungere-una-nuova-matrice-di-valori\/","og_site_name":"Excel Advisor","article_modified_time":"2023-12-10T06:20:03+00:00","og_image":[{"url":"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-tableau-dynamique-pour-redefinir-les-elements-1-2.png","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Tempo di lettura stimato":"1 minuto"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/exceladvisor.org\/it\/aggiungere-una-nuova-matrice-di-valori\/","url":"https:\/\/exceladvisor.org\/it\/aggiungere-una-nuova-matrice-di-valori\/","name":"Come aggiungere un nuovo valore a un array tramite VBA?","isPartOf":{"@id":"https:\/\/exceladvisor.org\/it\/#website"},"primaryImageOfPage":{"@id":"https:\/\/exceladvisor.org\/it\/aggiungere-una-nuova-matrice-di-valori\/#primaryimage"},"image":{"@id":"https:\/\/exceladvisor.org\/it\/aggiungere-una-nuova-matrice-di-valori\/#primaryimage"},"thumbnailUrl":"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-tableau-dynamique-pour-redefinir-les-elements-1-2.png","datePublished":"2023-11-17T21:24:59+00:00","dateModified":"2023-12-10T06:20:03+00:00","description":"In questo tutorial imparerai come aggiungere un nuovo valore a un array in VBA. Aggiungi il valore al nuovo oggetto che hai","breadcrumb":{"@id":"https:\/\/exceladvisor.org\/it\/aggiungere-una-nuova-matrice-di-valori\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/exceladvisor.org\/it\/aggiungere-una-nuova-matrice-di-valori\/"]}]},{"@type":"ImageObject","inLanguage":"it-IT","@id":"https:\/\/exceladvisor.org\/it\/aggiungere-una-nuova-matrice-di-valori\/#primaryimage","url":"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-tableau-dynamique-pour-redefinir-les-elements-1-2.png","contentUrl":"https:\/\/exceladvisor.org\/wp-content\/uploads\/2023\/08\/1-tableau-dynamique-pour-redefinir-les-elements-1-2.png"},{"@type":"BreadcrumbList","@id":"https:\/\/exceladvisor.org\/it\/aggiungere-una-nuova-matrice-di-valori\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/exceladvisor.org\/it\/"},{"@type":"ListItem","position":2,"name":"Come aggiungere un nuovo valore a un array tramite vba?"}]},{"@type":"WebSite","@id":"https:\/\/exceladvisor.org\/it\/#website","url":"https:\/\/exceladvisor.org\/it\/","name":"Excel Advisor","description":"Tips, Tricks, and Time-Saving Hacks","publisher":{"@id":"https:\/\/exceladvisor.org\/it\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/exceladvisor.org\/it\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"it-IT"},{"@type":"Organization","@id":"https:\/\/exceladvisor.org\/it\/#organization","name":"Excel Advisor","url":"https:\/\/exceladvisor.org\/it\/","logo":{"@type":"ImageObject","inLanguage":"it-IT","@id":"https:\/\/exceladvisor.org\/it\/#\/schema\/logo\/image\/","url":"https:\/\/exceladvisor.org\/it\/wp-content\/uploads\/2023\/12\/exceladvisor.org_.png","contentUrl":"https:\/\/exceladvisor.org\/it\/wp-content\/uploads\/2023\/12\/exceladvisor.org_.png","width":105,"height":36,"caption":"Excel Advisor"},"image":{"@id":"https:\/\/exceladvisor.org\/it\/#\/schema\/logo\/image\/"}}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/exceladvisor.org\/it\/wp-json\/wp\/v2\/pages\/1525","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/exceladvisor.org\/it\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/exceladvisor.org\/it\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/exceladvisor.org\/it\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/exceladvisor.org\/it\/wp-json\/wp\/v2\/comments?post=1525"}],"version-history":[{"count":1,"href":"https:\/\/exceladvisor.org\/it\/wp-json\/wp\/v2\/pages\/1525\/revisions"}],"predecessor-version":[{"id":2280,"href":"https:\/\/exceladvisor.org\/it\/wp-json\/wp\/v2\/pages\/1525\/revisions\/2280"}],"wp:attachment":[{"href":"https:\/\/exceladvisor.org\/it\/wp-json\/wp\/v2\/media?parent=1525"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}