Solved

VBA - random number between two numbers

Posted on 2013-06-12
5
682 Views
Last Modified: 2013-06-12
Looking for a function or whatever that will give a random number between two numbers.

So, for example, if i enter, a 1 and a 10, it would return a random number between 1 and 10.
0
Comment
Question by:patriotpacer
  • 3
  • 2
5 Comments
 
LVL 81

Accepted Solution

by:
zorvek (Kevin Jones) earned 500 total points
ID: 39242930
Use this formula:

=INT(RAND()*(Max-Min+1)+Min)

Kevin
0
 
LVL 33

Expert Comment

by:Norie
ID: 39242999
There's also RANDBETWEEN.
0
 
LVL 81

Expert Comment

by:zorvek (Kevin Jones)
ID: 39243013
RANDBETWEEN requires the Analysis ToolPak Add-In in Excel 2003 and earlier which is not always desired.

Kevin
0
 
LVL 33

Expert Comment

by:Norie
ID: 39243034
Kevin

You're right, guess I'm kind of used to most people having Excel 2007 or later.
0
 
LVL 81

Expert Comment

by:zorvek (Kevin Jones)
ID: 39243037
We're getting there but there are still some old installations.

Kevin
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

806 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question