I have several named ranges (timelinemarket, clientdetailsmarket, premisesmonthlymarket, cashinflowmarket, cashoutflowmarket) that I am looping through one by one and using .value to transfer to a new sheet. This requires a big chunk of code as I am looping through each individually and doing the .value action. All of the ranges are (or are made to be) the same height (72 rows, currently).
What I want is to add all of the values in the ranges to a single array which would look something like:
range 1 col 1 | range 1 col 2 | range 2 col 1 | range 3 col 1 | range 4 col 1 |
---|---|---|---|---|
value | value | value | value | value |
value | value | value | value | value |
value | value | value | value | value |
value | value | value | value | value |
Then I want to just take that array and paste it into the new worksheet at location x.
My understanding is that I could loop through the ranges one by one, add the values to the array, then use something like the below to put them into the new worksheet:
range("newrange") = myarray
The ranges to be processed will all be the same height, 72 rows, but they have different numbers of columns.
- Range 1: 72 rows x 2 columns
- Range 2: 72 rows x 1 column
- Range 3: 72 rows x 1 column
- Range 4: 72 rows x 1 column
Resulting Array: 72 rows x 5 columns
Value
property. For instancearr = Range("A1:B4").value
puts the range in an array having two columns and four rows. Is it a little clearer? You may test it. Then, use 'Debug.Print arr(2, 2)`. It will return the former range "B2" value... – FaneDuru