Solved

VBA - random number between two numbers

Posted on 2013-06-12
5
731 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 500 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
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 longer labels with horizontal bar charts instead of the vertical column chart.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

617 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