"Range("A1:A10") = Fill in the blank" so

goldfish

Well-known Member
Joined
Aug 23, 2005
Messages
712
I'm trying to recall a post I saw a few months ago that failed to show up in my searches. In it the poster used a formula to set multiple values without a loop. Something like
Code:
 Range("A1:A5") = Something
So that you would get
Code:
Column A
1
0
1
0
1
I know one possible way to do this would be
Code:
Range("A1:A5").Formula = "=Mod(ROW(),2)"
But I think I remember the values being constants rather than formulas.

So how do I assign an array of values to an range without a loop? or maybe a particular formula that can be evaluated right away, but all in a single line of code?

Thanks,
~Gold Fish
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
It might help if you told us the values/formulas you want to assign to the range.:)
 
Upvote 0
Like this?

Code:
Sub Test()
    Dim Something As Variant
    Something = Array("One", "Two", "Three", "Four", "Five")
    Range("A1:A5").Value = WorksheetFunction.Transpose(Something)
End Sub
 
Upvote 0
Exact Post I was looking for Richard! Thanks! Thats some pretty slick code!

Thanks all!

~Gold Fish
 
Upvote 0

Forum statistics

Threads
1,215,265
Messages
6,123,961
Members
449,135
Latest member
jcschafer209

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