I think this question has been asked a thousand times but after hours of searching I still can't find any help. So I need to use a vector of numbers as an input, do a calculation to all of those numbers and then return the results as a vector with a same dimension as the input vector. So lets say that I want to take some numbers and then subtract all of them by one and so my Excel sheet should look like this
A B
1 6 5
2 7 6
3 8 7
4 9 8
5 10 9
where column A is the input vector and B should be the output. But my output is only a column of zeros. Debugging also tells that the right numbers are there in the output vector but I can only print the first value which then goes to all cells. At the moment my code looks like this
Public Function Vector(values As Range) As Variant
Dim arraySize As Integer, i As Integer
arraySize = values.rows.Count
Dim returnArray() As Variant
ReDim returnArray(arraySize)
For i = 1 To arraySize
returnArray(i - 1) = values(i, 1) - 1
Next i
Vector = returnArray
End Function

Vector = returnArraygive you what you're expecting, i.e.Vectoris an array of values?