Solved

VBA - random number between two numbers

Posted on 2013-06-12
5
647 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
Comment Utility
Use this formula:

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

Kevin
0
 
LVL 33

Expert Comment

by:Norie
Comment Utility
There's also RANDBETWEEN.
0
 
LVL 81

Expert Comment

by:zorvek (Kevin Jones)
Comment Utility
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
Comment Utility
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)
Comment Utility
We're getting there but there are still some old installations.

Kevin
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now