Excel: Blank Seed Argument in RANDOM() Results in Error

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, "An error has occurred locating a support file or processing data for an add-in procedure."

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 "Microsoft Excel Function Reference" 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()*<range>) as the seed argument, where <range> 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().

  1. 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 "1," argument of the OFFSET() function.

  1. Select cell A1 and choose Define Name from the Formula menu. The word "Test" 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.

REFERENCES

"Microsoft Excel Function Reference," version 4.0, pages 345-346

"Microsoft Excel User's Guide 2," version 4.0, pages 38-40


KBCategory: kbtool
KBSubcategory:

Additional reference words: 4.0 4.00 4.0a 4.00a Analysis Tool Pack
ToolPak Pak


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: November 22, 1994
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.