View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
J. Sperry[_2_] J. Sperry[_2_] is offline
external usenet poster
 
Posts: 33
Default how to create an accumulated value

I think you'll need a macro. Assuming your random number is in cell B1 and
the accumulator is in cell B2:

Sub Macro1()
accum = Range("B2").Value
oldvalue = Range("B1").Value
Application.Calculate
newvalue = Range("B1").Value
If newvalue oldvalue Then Range("B2").Value = accum + 1
End Sub

"DaveM" wrote:

I have a random number generator between 81-88 which produces a new value
each time excel calculates.

I would like to count each time the value of the previous number generated
and the new number passes by a current value. Say 81.5. Here's my
questions...

1. Since i have to compare the previous number to the new number how do I
capture the previous number so it does not change and i can then compare it
to the new random number created?
2. How do i create an accumulator that counts the number of times the value
passes a given number say 81.5 when comparing the previous number to the
newly generated number. Again the random generator creates a number between
81-88 each time.

Thx
Dave