Populate cells in a row or column with the elements of an array

Hermac

New Member
Joined
Sep 5, 2016
Messages
28
Office Version
  1. 365
Platform
  1. Windows
Hello
This should be a simple problem but I'm not familiar with arrays. So please bear with me for a couple of minutes.
Let's take MyArray = ("John", "Jessica" , "Walter", "" , "Peter", "Jack", "Mary") , just to spread those names over [A1:G1] with a minimum of code.
I suppose an array is the shortest way. Is the "" between Walter en Peter necessary or will an ampty space between commas do?
And one more question, how many elements can an array carry?
Thank you very much.
Herman
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Hi,
You can test:
VBA Code:
Sheet1.Cells(1).Resize(, UBound(MyArray, 1) + 1) = MyArray
 
Upvote 0
What about
VBA Code:
Range("A1:G1").Value = Array("John", "Jessica", "Walter", "", "Peter", "Jack", "Mary")
 
Upvote 0
Solution
Thanks a lot Peter and James. I knew it wouldn't be to hard to do but it's very helpful and saved me a lot of surftime.
 
Upvote 0
You're welcome. Glad we could help. Thanks for the follow-up. :)
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,173
Members
452,615
Latest member
bogeys2birdies

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