"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
 

Some videos you may like

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,219
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
 

Watch MrExcel Video

Forum statistics

Threads
1,123,088
Messages
5,599,664
Members
414,325
Latest member
kfg1287

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