Hi. I have just started VBA programming and now I am stuck on this division matter. I want to construct an array of values generated by (A2-A1)/A1, (A3-A2)/A2 ... etc for whole values in A. I could make Macros to write out the values on the other column, but its too time consuming. There are around 3000 values in my column.
Here is what I managed to come up with:
Dim rarray() As Variant
n = Application.CountA(Range("E:E"))
ReDim rarray(1 To n)
Range("E3").Select
For i = 1 To n
rarray(i) = (ActiveCell.Value - ActiveCell.Offset(-1, 0).Value) / ActiveCell.Offset(-1, 0).Value
ActiveCell.Offset(1, 0).Select
Next i
The problem is that it gets me to an overflow error. I know its because of the / sign, if I put *, + or - it works fine. Can anyone suggest a solution or tell me whats wrong? and guide me to some info in the help files about operations on the elements of the array.
Here is what I managed to come up with:
Dim rarray() As Variant
n = Application.CountA(Range("E:E"))
ReDim rarray(1 To n)
Range("E3").Select
For i = 1 To n
rarray(i) = (ActiveCell.Value - ActiveCell.Offset(-1, 0).Value) / ActiveCell.Offset(-1, 0).Value
ActiveCell.Offset(1, 0).Select
Next i
The problem is that it gets me to an overflow error. I know its because of the / sign, if I put *, + or - it works fine. Can anyone suggest a solution or tell me whats wrong? and guide me to some info in the help files about operations on the elements of the array.