Array of Values into Range in One Move

Castle7

New Member
Joined
Jul 7, 2008
Messages
2
I have a vector of values and a range that is the same size as the vector. I want to paste the values of this vector into the range in one shot WITHOUT using a for loop.

If v is the vector, r is the range, and i is the counter variable, I am trying to avoid this:

For i = 1 To UBound(v)
r(i).Value = v(i)
Next i

I'm looking for something like:
r.value = v
but of course this doesn't work
 
Last edited:

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
You need to tell us the range.
Code:
arr = Array("A", "B", "C", "D", "E")
' rows
Set rng = Range("A1:A5")
rng.Value = Application.Transpose(arr)
' columns
Set rng = Range("B1:F1")
rng.Value = arr
 
Upvote 0
Thanks Norie - Your reply solved my problem.

I was trying to do rows but did not transpose the vector.
 
Upvote 0

Forum statistics

Threads
1,214,594
Messages
6,120,436
Members
448,964
Latest member
Danni317

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top