View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Robert Bruce[_2_] Robert Bruce[_2_] is offline
external usenet poster
 
Posts: 108
Default Unexpected result copying an array

Roedd <<Schizoid Man wedi ysgrifennu:

Hi,

I have a single column of numbers from 1 to 10. I've written the
following function to replicate these numbers in another column using
the matrix enter (Ctrl-Shift-Enter).


Your output array needs to be two dimensional:

Public Function copyArr(wk As Range) As Integer()

Dim outArr() As Integer
Dim i As Integer

i = wk.Rows.Count

Dim c As Integer
ReDim outArr(1 To i, 1 To 1) As Integer

For c = 1 To i
outArr(c, 1) = wk(c)
Next c

copyArr = outArr

End Function

HTH

Rob