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

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,358
Office Version
  1. 365
Platform
  1. Windows
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

Castle7

New Member
Joined
Jul 7, 2008
Messages
2
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,190,565
Messages
5,981,707
Members
439,732
Latest member
TC_vii

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
Top