Forum Discussion
amrsalah
Jun 17, 2021Copper Contributor
Cumulative roundup
Hi All, I have a case that its calculation is a cumulative after rounding the number, for example; I have starting number (e.g. 7000) this number is growing each time by 15% taking in consideration ...
amrsalah
Jun 23, 2021Copper Contributor
Thank you.
But what I need is to be updated automatically in the same cell according to a variable in the formula indicated the number of the instance, for example if this instance 1 so the result is 7000, if 2 the result should be 8100, and so on...
But what I need is to be updated automatically in the same cell according to a variable in the formula indicated the number of the instance, for example if this instance 1 so the result is 7000, if 2 the result should be 8100, and so on...
JMB17
Jun 23, 2021Bronze Contributor
Another option would be to use a custom vba function.
Function MyRoundup(base As Double, multiplier As Double, numDigits As Integer, index As Integer) As Variant
Dim res As Double, i As Long
If index <= 0 Then
MyRoundup = CVErr(xlErrValue)
Exit Function
End If
res = base
For i = 1 To index - 1
res = Application.RoundUp(res * multiplier, numDigits)
Next i
MyRoundup = res
End Function
To use the function, you would copy/paste into a standard code module. Then, to find the 5th element, you would enter enter:
=myroundup(7000,115%,-2,5)