"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

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,351
Office Version
  1. 365
Platform
  1. Windows
It might help if you told us the values/formulas you want to assign to the range.:)
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
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
 

goldfish

Well-known Member
Joined
Aug 23, 2005
Messages
712
Exact Post I was looking for Richard! Thanks! Thats some pretty slick code!

Thanks all!

~Gold Fish
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,167,816
Messages
5,855,798
Members
431,765
Latest member
RedleoUK

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