how to create an accumulated value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

INDES and #Value! 1
Random Numbers 4
Substituting values 1
excel doc 2
Random Number Generation at Interval 1
Automatically adding values to cells... 3
random number in a cell 1
VBA "Rnd" Function: Truly Random? 2

Back
Top