?
Solved

VBA - random number between two numbers

Posted on 2013-06-12
5
Medium Priority
?
750 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
[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
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 81

Accepted Solution

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

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

Kevin
0
 
LVL 34

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 34

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

718 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