<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: In Excel, How Do I Add Up All The Random Values So That They Must Equal To 1?</title>
	<atom:link href="http://skyndt.com/2009/06/13/in-excel-how-do-i-add-up-all-the-random-values-so-that-they-must-equal-to-1/feed/" rel="self" type="application/rss+xml" />
	<link>http://skyndt.com/2009/06/13/in-excel-how-do-i-add-up-all-the-random-values-so-that-they-must-equal-to-1/</link>
	<description>UAV Inspection Solutions</description>
	<lastBuildDate>Wed, 14 Oct 2009 20:00:14 -0600</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Elmyr</title>
		<link>http://skyndt.com/2009/06/13/in-excel-how-do-i-add-up-all-the-random-values-so-that-they-must-equal-to-1/comment-page-1/#comment-1081</link>
		<dc:creator>Elmyr</dc:creator>
		<pubDate>Sat, 13 Jun 2009 21:57:54 +0000</pubDate>
		<guid isPermaLink="false">http://skyndt.com/2009/06/13/in-excel-how-do-i-add-up-all-the-random-values-so-that-they-must-equal-to-1/#comment-1081</guid>
		<description>Hit Alt+F11 to open VBA editor. Select Insert &gt; Module and paste the code below in the window that opens. I think this is what you&#039;re looking for. If you expand the number of rows or columns, change the value of the constants at the beginning of the code.
Option Explicit
Public Const numCols = 11
Public Const numRows = 11
Sub Generate_Data()
Dim total As Double
Dim adjustment As Double
Dim r As Integer
Dim c As Integer
Dim numArray(numRows, numCols) As Double
    For r = 1 To numRows
        &#039;Generate Random Numbers
        total = 0
        For c = 1 To numCols
            Randomize
            numArray(r, c) = Rnd()
            total = total + numArray(r, c)
        Next c
        &#039;Adjust Numbers so sum of row will be 1
        adjustment = 1 / total
        For c = 1 To numCols
            numArray(r, c) = numArray(r, c) * adjustment
        Next c
    Next r
    &#039;Output numbers to spreadsheet, assuming row 1 is header row and data begins in the second row
    For r = 1 To numRows
        For c = 1 To numCols
            Cells(r + 1, c).Value = numArray(r, c)
        Next c
    Next r
End Sub
Edit: If you don&#039;t want to use VBA, you could use two separate tables, one with the random numbers, and one where you adjust the numbers based on the totals from the original table. The numbers in the second table would = the original numbers * (1 / the original total of that row).</description>
		<content:encoded><![CDATA[<p>Hit Alt+F11 to open VBA editor. Select Insert > Module and paste the code below in the window that opens. I think this is what you&#8217;re looking for. If you expand the number of rows or columns, change the value of the constants at the beginning of the code.<br />
Option Explicit<br />
Public Const numCols = 11<br />
Public Const numRows = 11<br />
Sub Generate_Data()<br />
Dim total As Double<br />
Dim adjustment As Double<br />
Dim r As Integer<br />
Dim c As Integer<br />
Dim numArray(numRows, numCols) As Double<br />
    For r = 1 To numRows<br />
        &#8216;Generate Random Numbers<br />
        total = 0<br />
        For c = 1 To numCols<br />
            Randomize<br />
            numArray(r, c) = Rnd()<br />
            total = total + numArray(r, c)<br />
        Next c<br />
        &#8216;Adjust Numbers so sum of row will be 1<br />
        adjustment = 1 / total<br />
        For c = 1 To numCols<br />
            numArray(r, c) = numArray(r, c) * adjustment<br />
        Next c<br />
    Next r<br />
    &#8216;Output numbers to spreadsheet, assuming row 1 is header row and data begins in the second row<br />
    For r = 1 To numRows<br />
        For c = 1 To numCols<br />
            Cells(r + 1, c).Value = numArray(r, c)<br />
        Next c<br />
    Next r<br />
End Sub<br />
Edit: If you don&#8217;t want to use VBA, you could use two separate tables, one with the random numbers, and one where you adjust the numbers based on the totals from the original table. The numbers in the second table would = the original numbers * (1 / the original total of that row).</p>
]]></content:encoded>
	</item>
</channel>
</rss>
