Microsoft KB Archive/83313

{| = Excel: Blank Seed Argument in RANDOM Results in Error =
 * width="100%"|

Last reviewed: November 22, 1994

Article ID: Q83313 The information in this article applies to:


 * Microsoft Excel for Windows, versions 4.0 and 4.0a

SUMMARY
Microsoft Excel version 4.0 includes an add-in function, RANDOM, that generates a set of random numbers. When you use this function in a macro, if you leave the seed argument blank, the macro stops execution and Microsoft Excel displays the error message, &quot;An error has occurred locating a support file or processing data for an add-in procedure.&quot;

MORE INFORMATION
The RANDOM macro function is parallel to choosing Analysis Tools from the Options menu and selecting Random Number Generation from the Analysis Tools list. Using the Options menu method, it is not necessary to place a seed value in the Random Seed box. Microsoft Excel still generates random numbers.

Although the &quot;Microsoft Excel Function Reference&quot; lists the seed argument as optional when using the RANDOM macro function, omitting it generates the error mentioned above. To avoid the error, use any integer value between 0 (zero) and 32767 in the seed argument.

Note, however, that if you use a constant number other than 0, RANDOM will generate the same set of numbers each time your macro runs. To generate different numbers, use 0 or INT(RAND* ) as the seed argument, where represents the upper limit of the numbers you want to use for seed values. For example, to generate seed values between 0 and 9, use 10 as your range value, for seed values between 0 and 99 use 100, and so on.

Example
The following sample macro demonstrates the use of the function RANDOM.

  Enter the following into a macro sheet: A1: Test A2: =RANDOM(OFFSET(ACTIVE.CELL,0,0,5,2),2,5,1,5,10,20) A3: =RANDOM(OFFSET(ACTIVE.CELL,6,0,5,2),2,5,1,        INT(RAND*10),10,20) A4: =RETURN 

NOTE: The formula in cell A3 should be entered as one single line, such that the INT function follows the &quot;1,&quot; argument of the OFFSET function.
 * 1) Select cell A1 and choose Define Name from the Formula menu. The word &quot;Test&quot; will show in the Name box and the Refers To box will show $A$1. Select the Command option in the Macro section and choose OK.
 * 2) From the File menu, choose New. Select Worksheet and choose OK.
 * 3) With cell A1 selected, choose Run from the Macro menu. Select the Test macro and choose OK. The macro will generate two groups of random numbers.
 * 4) Select cell D1 on the worksheet and repeat Step 4.

Note that the numbers in the top group in both cases are the same while the numbers in the bottom group are different. This is a result of using 0 or the RAND function as the seed argument as opposed to using a constant number.