Generate random number from 1-100 inclusive?

G

Guest

= Round(Rnd() * 100, 0)

The above code is generating random numbers from 0-100. How can I alter it
to generate only 1-100?
 
G

Guest

Try multiple use of the function like this --
= IIf(Round(Rnd()*100,0)=0,Round(Rnd()*100,0),Round(Rnd()*100,0))

The odds of both instances comming up zero at the same time is kinda high.
 
S

Smartin

KARL said:
Try multiple use of the function like this --
= IIf(Round(Rnd()*100,0)=0,Round(Rnd()*100,0),Round(Rnd()*100,0))

The odds of both instances comming up zero at the same time is kinda high.

Holey moley!

What's wrong with = Round(Rnd() * 99, 0) + 1 ?
 
G

Guest

THAT was the trick, thank you. I used to know this, back in the '70s,
programming games in BASIC, lol.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top