{"id":12189,"date":"2014-04-11T17:46:39","date_gmt":"2014-04-11T17:46:39","guid":{"rendered":"http:\/\/www.learnexcelmacro.com\/wp\/?p=3290"},"modified":"2022-09-14T13:03:08","modified_gmt":"2022-09-14T13:03:08","slug":"array-to-rows","status":"publish","type":"post","link":"https:\/\/vmlogger.com\/excel\/2014\/04\/array-to-rows\/","title":{"rendered":"Spreading an Array values across Rows in Excel – VBA"},"content":{"rendered":"
This is an extension to my previous Article. <\/a> Where we learned the best way to spread array values across columns in Excel. Here I will teach you how to spread Array values across Rows in Columns.<\/p>\n In the previous code, there are TWO changes that need to be done. Just changing the Range address across Rows will not help in achieving this distribution of array values across rows. This is the main reason for writing this as a separate article. Following are the two changes that need to be done to distribute the array values across rows:<\/p>\n <\/p>\n <\/p>\n <\/p>\n This is an extension to my previous Article. Where we learned the best way to spread array values across columns in Excel. Here I will teach you how to spread Array values across Rows in Columns. How it works? How it is different from the previous code? In the previous code, there are TWO changes […]<\/p>\n","protected":false},"author":45,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[1246,1682],"tags":[],"class_list":["post-12189","post","type-post","status-publish","format-standard","hentry","category-macro","category-popular-articles"],"yoast_head":"\nHow it works? How it is different from the previous code? <\/h3>\n
\n
Code for Array values across rows\u2013 Using Array to Range<\/h3>\n
\r\nSub SpreadUsingArrayToRange()\r\n 'This function will spread the array values using For Array to Range\r\n Dim i As Integer\r\n Dim myArr(10000) As Variant\r\n \r\n 'fill values in this array\r\n For i = 0 To UBound(myArr) - 1\r\n myArr(i) = \"This Is my data \" & i\r\n Next\r\n 'myArr has 10000 values in it.\r\n 'to spread these 10000 values, here we will use an array to range\r\n 'To spread it across rows, We just need to transpose the array before assigning\r\n Range(\"A1:A\" & UBound(myArr)).Value = Application.Transpose(myArr)\r\nEnd Sub\r\n<\/code><\/pre>\n
To know more about Range and Array distribution in detail, you can read this article.<\/a> <\/h3>\n<\/span>","protected":false},"excerpt":{"rendered":"