Forum Discussion
johnnynaunny
Jan 03, 2024Copper Contributor
Need Function to get previous calculated value of a cell
New to the Community and VBA so please bear with me. I'm using Microsoft 365 Excel v16.82 on a Mac. I'd like to be able to use a previous cell's calculated value to compare with its new value and...
Rodrigo_
Jan 04, 2024Iron Contributor
Hello johnnynaunny
You can create a custom function in VBA to achieve this. Here’s an example of how you might write this function:
Function UpdateMax(currentValue As Double, previousMax As Double) As Double
If currentValue > previousMax Then
UpdateMax = currentValue
Else
UpdateMax = previousMax
End If
End Function
Then use the created function in your cell B4
=UpdateMax(B3, B4)
johnnynaunny
Jan 04, 2024Copper Contributor
Thanks for the quick reply. Unfortunately using B4 as am input and output creates a circular ref.