A
Andy Chan
Dear all,
I want to write a user-defined function to output an array. But I don't
know its codes. For example, if I want to define a function MyFunction(A,B)
where A, B are positive integers which generates an array such that the
entry in the x-th row, y-th column is x+y, what codes should I write? Should
it be like this:
Function MyFunction (A As Integer, B As Integer) As Range
dim R As Range
dim X As Integer
dim Y As Integer
redim R(A,B)
For X = 1 to A
For Y = 1 to B
R.Cells(X,Y)=X+Y
Next Y
Next X
MyFunction = R
End Function
Thanks in advance.
Best Regards,
Andy
I want to write a user-defined function to output an array. But I don't
know its codes. For example, if I want to define a function MyFunction(A,B)
where A, B are positive integers which generates an array such that the
entry in the x-th row, y-th column is x+y, what codes should I write? Should
it be like this:
Function MyFunction (A As Integer, B As Integer) As Range
dim R As Range
dim X As Integer
dim Y As Integer
redim R(A,B)
For X = 1 to A
For Y = 1 to B
R.Cells(X,Y)=X+Y
Next Y
Next X
MyFunction = R
End Function
Thanks in advance.
Best Regards,
Andy