VBA especial random numbers generator with option includes or exclude

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
2,422
Office Version
  1. 2010
Hello

I am looking for a lottery 5/50 exclusive random number generators I search in the Mr.Excel forums and also in Internet but do not find it.

With following features…
I will make a list of numbers need to Excluded in row 2 or numbers to be Include in row 3


  1. VBA give an input option for both 1st input exclude so I can select the numbers to be excluded from the row2, if I do not want to exclude any skip this step, and 2nd input include may be 1,2 or max 3 numbers, if I do not want to include any skip this step, (so within set of 5 included number must be picked rest random numbers be added to make 5 in total)
  2. Input option how many sets require for example 5, 10, 15, or 20 random sets output them in B6:F15
  3. If possible (not important) output numbers could be organized in ascending order smaller to higher will the better.

Example...


Book1
ABCDEFGHIJKLMN
1
2Exclude27122227323840424547
3Include2047
4
5n1n2n3n4n5
6Set 01526313637
7Set 021316192135
8Set 03830374148
9Set 041017181941
10Set 05813213134
11Set 061416233637
12Set 07417192834
13Set 081025464849
14Set 0915153044
15Set 101123243048
16
Sheet1


Thanks In Advance
Using version 2000

Regards,
Moti
 
B___P, thank you for explaining the logic I understand.

But if possible I want input selection for excluded included number from range and desire numbers of set to be generated is any way to do it.

I appreciate you help

Regards,
Moti
 
Upvote 0

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Hello Rick Rothstein, thank you for your response
which can generate 10 sets at once VBA is run out of 1 to 50 numbers each set of 5 numbers
Regards,
Moti
Hello Rick Rothstein,

Sorry I want to make a correction not 10 fix, I want as per input options may be 1, 5, 10 or 50...

Thank you

Regards,
Moti
 
Upvote 0
macro already does what you want:
put excluded numbers in row 2 from column B on. Answer yes to 1st question
put included numbers in row 3 from column B on. Answer yes to 2nd question

if you want a custom set of ticket answer No to "Free numbers only once" and random numbers may repeat over tickets. If answer is yes numbers apart excluded and included appear only once.
 
Upvote 0
macro already does what you want:
Hello B___P,

Thank you very much, and my apologies for not testing it thoroughly.

In the Step3 question NO REPETITIONS? I was answering every time only "YES"

if you want a custom set of ticket answer No
B___P, yes this did the trick answering "No" give me the option "How many sets?"

Sorry, and many thanks All was perfect already.

Regards,
Moti
:)
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,175
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top