PDA

View Full Version : Solved: Range Array



NewDaddy
03-01-2007, 03:26 AM
Hi All

Most likely a very simple question but cannot fathom this?

Range("C1:C4").Value = Array("North", "South", "West","East")

Why does the above return "North" in cells C1:C4 and not the following?
C1 - North
C2 - South
C3 - West
C4 - East

The above works fine when the range is C1:F1. How can I get the above 'headings' to return in C1 to C4?

Thanks for the explanation and solution.

Cheers
Jay

Bob Phillips
03-01-2007, 03:35 AM
You need to transpose it



Range("C1:C4").Value = Application.Transpose(Array("North", "South", "West", "East"))

NewDaddy
03-01-2007, 03:43 AM
Hi xld

Thank you very much.
That actually makes sence!!

Cheers
jay

Bob Phillips
03-01-2007, 03:50 AM
It does when you know that it works okay in a horizontal range.

The point is that a range is rows and columns, even if you only use one of either. The array command creates a 1-d array of columns, hence the need to transpose.