Solved

# VBA - random number between two numbers

Posted on 2013-06-12
719 Views
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
Question by:patriotpacer
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 3
• 2

LVL 81

Accepted Solution

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

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

Kevin
0

LVL 34

Expert Comment

ID: 39242999
There's also RANDBETWEEN.
0

LVL 81

Expert Comment

ID: 39243013
RANDBETWEEN requires the Analysis ToolPak Add-In in Excel 2003 and earlier which is not always desired.

Kevin
0

LVL 34

Expert Comment

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

ID: 39243037
We're getting there but there are still some old installations.

Kevin
0

## Featured Post

Question has a verified solution.

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

### Suggested Solutions

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article describes a serious pitfall that can happen when deleting shapes using VBA.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
###### Suggested Courses
Course of the Month4 days, 12 hours left to enroll