Attached is NumberPicker.xlsm, a one-sheet workbook that lets users pick numbers for the Mega Millions and Powerball lotteries. NumberPicker picks five sets of numbers, then the user transfers them manually to a playslip.
NumberPicker works fine as far as it goes, but it is somewhat inelegant. Two improvements would polish things up, and I’m looking for help in making them:
-
[*]First, when presented to the user for transcribing, the five chosen numbers should be sorted from low to high. Right now, they appear in random order. (The sixth number, Mega Ball or Powerball, stands alone, and is not sorted with the others.)
[*]
[*]Second, there should be no duplicates among the five chosen numbers. Right now, an Alternate number is provided; when he fills in the playslip, the user can substitute it for the first duplicate if there is one. If there are triplicates or more, the user just picks a new set of numbers.
I have a strategy in mind for implementing the improvements, but there may be better ways to do it. My Excel and VBA skills aren’t up to implementing even my own strategy, which is:
-
[*]Bear in mind that the Mega Millions needs five numbers from 1-74, and a separate number from 1-15. (Powerball needs five numbers from 1-69 and one from 1-26.)
[*]Get rid of the Alternate numbers, and remove the formulas from the areas under Playslip Games A through E.
[*]Make separate command buttons for Mega Millions and Powerball.
[*]Click the Mega Millions command button to recalculate and start the process below
[*]In a remote corner of the worksheet, do the following for Mega Millions. Powerball would be similar…
[*]Use RANDBETWEEN to put 5 Mega Millions numbers, plus a Mega Ball, in a range somewhere out of sight. Call it MegRandom.
[*]Copy MegRandom to the Clipboard
[*]Using Paste Values, put MegRandom into a range of cells somewhere out of sight. Call it MegValues. (The pasting will cause the workbook to recalculate, putting different numbers in MegRandom).
[*]Sort MegValues from low to high.
[*]Look for duplicates in MegValues. If you find any, go back to Step 7.
[*]Once MegValues has been sorted and there are no duplicates, copy it and paste it into the range under Playslip Game A in the main area of the sheet.
[*]Repeat the above four times, pasting into the ranges under Playslip Games B, C, D, and E.
[*]Something similar would happen when the Powerball command button is clicked, except RANDBETWEEN would use the Powerball ranges of acceptable numbers, and the pasting would be into Playslip Games under the Powerball Numbers.
Does any of this make sense?