Solved

VBA - random number between two numbers

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

821 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