Microsoft Office Tutorials and References

In Depth Information

**Generating and Using Random Numbers**

The syntax for using the ROUND function with the RAND function follows:

=ROUND(RAND() * (high number-low number) + low number,0)

Try it yourself! Here’s how to use RAND and INT together:

1. Position the pointer in the cell where you want the results displayed.

2. Enter
=INT((
to begin the formula.

3. Click the cell that has the highest number to be used, or enter such

a value.

4. Enter
– (a minus sign).

5. Click the cell that has the lowest number to be used, or enter such

a value.

6. Enter
+1) * RAND() +
.

7. Click again on the cell that has the lowest number to be used, or enter

the value again.

8. Type a
), and press Enter.

A random number, somewhere in the range of the low and high number, is

returned.

Table 8-1 shows how returned random numbers can be altered with the INT

and ROUND functions.

Table 8-1

Using INT and ROUND to Process Random Values

Value

Value Returned with INT

Value Returned with ROUND

51.71777896

51

52

27.20727871

27

27

24.61657068

24

25

55.27298686

55

55

49.93632709

49

50

43.60069745

43

44

Table 8-1 points out how the INT and ROUND functions return different

numbers. For example, 51.71777896 is more accurately rounded to 52. Bear in

mind that the second argument in the ROUND function, 0 in this case, has an

effect on how the rounding works. A 0 tells the ROUND function to round the