Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
inkpassion
 
Posts: n/a
Default Random Values totaling Cell value


What Im looking to do is have 2 cells 1 with the number of random
numbers and 2 the total value of these numbers. I need the random
numbers to be 1-6.

Something like this:

Coins Value
4 10

C1 C2 C3 C4
1 4 3 2


What would the formula be to accomplish this?



--
inkpassion
------------------------------------------------------------------------
inkpassion's Profile: http://www.excelforum.com/member.php...o&userid=16972
View this thread: http://www.excelforum.com/showthread...hreadid=401757

  #2   Report Post  
Bryan Hessey
 
Posts: n/a
Default


In cells C1 to C4 set

=INT(RAND()*6+1)

In the 'count' cell

=COUNT(C1:C4)
(this would always appear to be 4)

In the sum cell,

=SUM(C1:C4)

Did you intend the 'count' cell to be a count of the variety of numbers
given ?
(ie, for a 1, 2, 3, 3 selection to show 3)
or did you intend that cells C1 to C4 all have different 'random'
numbers ?




inkpassion Wrote:
What Im looking to do is have 2 cells 1 with the number of random
numbers and 2 the total value of these numbers. I need the random
numbers to be 1-6.

Something like this:

Coins Value
4 10

C1 C2 C3 C4
1 4 3 2


What would the formula be to accomplish this?



--
Bryan Hessey
------------------------------------------------------------------------
Bryan Hessey's Profile: http://www.excelforum.com/member.php...o&userid=21059
View this thread: http://www.excelforum.com/showthread...hreadid=401757

  #3   Report Post  
Max
 
Posts: n/a
Default

One quick set-up to try ..

Assume A1:B1 contain the labels: Coins, Value
Input the number of coins in A2, say enter: 4

Put in B2: =SUM(C:C)
Put in C1:
=IF(OR($A$2="",ROWS($A$1:A1)$A$2),"",RANDBETWEEN( 1,6))
Copy C1 down to say, C20, to cover the max expected number (of coins)
that will be input in A2

The above will give you the set-up that you're after.

B2 provides the sum of the random numbers generated in col C, while the
number of cells "activated" in col C will be dependent on the input in A2

Note that RANDBETWEEN requires the Analysis Toolpak
to be installed and activated.

Check the "Analysis Toolpak" box (via Tools Add-Ins)

Chip Pearson's page has details on the ATP at:
http://www.cpearson.com/excel/ATP.htm

Alternatively, we could replace RANDBETWEEN(1,6) in the formula
with: INT(RAND()*6+1)
(as suggested by Bryan)

i.e. put instead in C1:
=IF(OR($A$2="",ROWS($A$1:A1)$A$2),"",INT(RAND()*6 +1))
and copy down to C20 as before
--
Rgds
Max
xl 97
---
Singapore, GMT+8
xdemechanik
http://savefile.com/projects/236895
--
"inkpassion" wrote
in message ...

What Im looking to do is have 2 cells 1 with the number of random
numbers and 2 the total value of these numbers. I need the random
numbers to be 1-6.

Something like this:

Coins Value
4 10

C1 C2 C3 C4
1 4 3 2


What would the formula be to accomplish this?



--
inkpassion
------------------------------------------------------------------------
inkpassion's Profile:

http://www.excelforum.com/member.php...o&userid=16972
View this thread: http://www.excelforum.com/showthread...hreadid=401757



  #4   Report Post  
Max
 
Posts: n/a
Default

After the number is input in A2, if you wish to regenerate the random
numbers in col C, just press the F9 key
--
Rgds
Max
xl 97
---
Singapore, GMT+8
xdemechanik
http://savefile.com/projects/236895
--


  #5   Report Post  
inkpassion
 
Posts: n/a
Default


You got me on a good start but I didnt make myself clear (sorry!)

What I need is the random numbers to total a value entered by a user.
So In this game I will need 5 coins that add up to 20. I enter in the
20points spread over 5 coins and then it random outputs 5 numbers that
total up to 20.


--
inkpassion
------------------------------------------------------------------------
inkpassion's Profile: http://www.excelforum.com/member.php...o&userid=16972
View this thread: http://www.excelforum.com/showthread...hreadid=401757



  #6   Report Post  
Max
 
Posts: n/a
Default

I'm not sure there's a way to fulfil this directly,
but try this slight variation to the earlier construct ..
(link to a sample file is provided below)

Instead of the formula in B2,
enter the target value in B2, e.g.: 20

Put a label in say, A4: Target reached?
Put in A5: =IF(SUM(C:C)=B2,"Yes!!","")

The Gameplay will go along these lines
--------------------------------------------
a. Enter the number of coins and the target value in A2:B2.

b. Tap F9 key to regenerate the random values in col C until a "Yes!!"
appears in A5, signalling target value reached

c. Freeze the results of the random values in col C elsewhere with a copy
paste special values ok

Here's a link to a sample file with the construct to play with:
http://www.savefile.com/files/5917225
File: Random Values Totalling Cell Value _inkpassion_misc.xls
--
Rgds
Max
xl 97
---
Singapore, GMT+8
xdemechanik
http://savefile.com/projects/236895
--
"inkpassion" wrote
in message ...

You got me on a good start but I didnt make myself clear (sorry!)

What I need is the random numbers to total a value entered by a user.
So In this game I will need 5 coins that add up to 20. I enter in the
20points spread over 5 coins and then it random outputs 5 numbers that
total up to 20.


--
inkpassion
------------------------------------------------------------------------
inkpassion's Profile:

http://www.excelforum.com/member.php...o&userid=16972
View this thread: http://www.excelforum.com/showthread...hreadid=401757



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
cell validation even for values pasted into cells JR_06062005 Excel Worksheet Functions 2 July 13th 05 05:36 PM
cell color index comparison MINAL ZUNKE New Users to Excel 1 June 30th 05 07:11 AM
Why will solver only return the original adjustable cell values? Del Excel Worksheet Functions 0 March 3rd 05 12:25 AM
Toggle multiple values in single cell Chandni Excel Worksheet Functions 5 February 10th 05 12:48 AM
GET.CELL Biff Excel Worksheet Functions 2 November 24th 04 07:16 PM


All times are GMT +1. The time now is 04:12 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"