0

This question already has an answer here:

I'm wanting to create a button that generates a string of 10 random numbers into cells, and pulls the range for these random numbers from, for instance, in B1 and B2. Basically, I'm looking to use the INDIRECT() function in VBA. Is there a way to do this?

marked as duplicate by nixda, Mokubai Jan 27 '15 at 18:28

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 3
    What kind of random numbers? Decimals? Whole numbers? Have you looked at using RAND() or RANDBETWEEN()? – Excellll Jan 26 '15 at 19:46
  • I have. I want it to be a button so I have better control over when the numbers are generated. I'm looking for whole numbers only. I know how to create a button that generates a number between a predefined range, but I'm looking to make it pick numbers from a user-defined range. – Martin Jan 26 '15 at 20:27
  • What do you have working so far? Have you attempted anything yet? Give it a try and share with us how it went. We will help you from there. – CharlieRB Jan 26 '15 at 20:47
1

Place one of the limits in B1 and the other in B2

In A1 enter:

=RANDBETWEEN(MIN($B$1,$B$2),MAX($B$1,$B$2))

and copy down thru A10

Put a button somewhere on the sheet and assign this macro to it:

Sub marine()
    Application.Calculate
End Sub



enter image description here

Not the answer you're looking for? Browse other questions tagged or ask your own question.