ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Unexpected result copying an array (https://www.excelbanter.com/excel-programming/370758-re-unexpected-result-copying-array.html)

Robert Bruce[_2_]

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




All times are GMT +1. The time now is 04:33 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com