Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
BaldySlaphead
 
Posts: n/a
Default Recording incidences of results of a RAND() fucntion.


I have a random function which generates an integer from 1-9 with each
screen refresh.

Would I be able to tally how many times each number was generated? What
I imagined was setting up an additional COL 'Results' and then trying to
increment an

-if [Cell Ref of Rand Function]=1 then x (cell containing tally of
incidence of result 1) =x+1

if [Cell Ref of Rand Function]=2 then x (cell containing tally of
incidence of result 2) =x+1 - etc. etc.

style argument. Thus I could see how often a number was picked by the
RAND.

Is this possible, and how might I do it? Any comments gratefully
received.

Thanks for looking!

Baldy


--
BaldySlaphead
------------------------------------------------------------------------
BaldySlaphead's Profile: http://www.excelforum.com/member.php...fo&userid=1260
View this thread: http://www.excelforum.com/showthread...hreadid=387444

  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

You could use a worksheet event that checks that cell after every recalculation,
but that seems like you could lose control pretty quickly (excel can recalculate
lots of times and you may not be prepared for that).

I think I would use a dedicated macro.

I put =randbetween(1,10) in A1 (I had to have the analysis pack addin loaded)

Then I had used this macro to count the results.

Option Explicit
Sub testme()

Dim myCell As Range
Dim myRng As Range
Dim iCtr As Long
Dim MaxTimes As Long

MaxTimes = 10

With Worksheets("Sheet1")
Set myCell = .Range("a1")
Set myRng = .Range("b1:B10") '<- ten cells!

myRng.ClearContents 'start new each time?
For iCtr = 1 To MaxTimes
Application.Calculate
myRng(myCell.Value) = myRng(myCell.Value) + 1
Next iCtr
End With

End Sub

If calculation is set to automatic, just incrementing the cell causes a recalc.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

BaldySlaphead wrote:

I have a random function which generates an integer from 1-9 with each
screen refresh.

Would I be able to tally how many times each number was generated? What
I imagined was setting up an additional COL 'Results' and then trying to
increment an

-if [Cell Ref of Rand Function]=1 then x (cell containing tally of
incidence of result 1) =x+1

if [Cell Ref of Rand Function]=2 then x (cell containing tally of
incidence of result 2) =x+1 - etc. etc.

style argument. Thus I could see how often a number was picked by the
RAND.

Is this possible, and how might I do it? Any comments gratefully
received.

Thanks for looking!

Baldy

--
BaldySlaphead
------------------------------------------------------------------------
BaldySlaphead's Profile: http://www.excelforum.com/member.php...fo&userid=1260
View this thread: http://www.excelforum.com/showthread...hreadid=387444


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
calculating results in formulas Linda Excel Discussion (Misc queries) 9 July 6th 05 09:20 AM
DATE.DIFF results in French jenhow Excel Discussion (Misc queries) 2 February 15th 05 06:52 PM
I want the results of a formula to show in cell, NOT THE FORMULA! ocbecky Excel Discussion (Misc queries) 4 December 10th 04 08:39 PM
displaying results and not formulas Marc S Excel Worksheet Functions 2 November 11th 04 01:34 PM
?odd results for =left(F#,2) Steven Stadelhofer Excel Worksheet Functions 1 November 4th 04 09:54 PM


All times are GMT +1. The time now is 09:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"