Results 1 to 10 of 10
  1. #1
    New Lounger
    Join Date
    Mar 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Looking for a Macro or VBA to help with my problem

    I need a macro or VBA to generate Lottery Combinations for Mega Millions & Power ball, I got 2 workbooks that I want to work together I uploaded 1 workbook but I couldn't upload the 2nd one because it's over 9 megs. the 1st one I want to generate combination numbers from Mega Millions or Power Ball & then compare the generated Combinations to the workbook 'VA. Lottery Winning Combinations' & delete any duplicates combinations from the generated combinations of the game that I want to play. The 'VA. Lottery Winning Combinations' workbook since I couldn't upload it here is how I got it setup, Mega Millions Header is A1-G1 & the DATE in Column A2 - A1781 & the winning combinations is B2 - G1781. The Power Ball Header is I1-O1 & the DATE in Column I2-I1735 & the winning combinations is J2 - O1735. I hope that I explained this correctly any help would be appreciated.
    Attached Files Attached Files
    Last edited by studfin; 2014-06-12 at 22:03.

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts
    I don't understand your request. And without even a sample of the 2nd file, I don't see how we are going to work with it. You should not expect us to create a sample. It does not have to be completely filled out, just attach a sample with example data that we can work with to test any code developed

    Please explain in detail, what you want the macro to do exactly. If it needs to delete anything, how it should determine what to delete and where it should be deleting, and other ways the 2 files should be interacting.

    Steve

  3. #3
    New Lounger
    Join Date
    Mar 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hey sdckapr Sorry my Bad

    I uploaded a sample of the 2nd Workbook 'VA. Lottery Winning Combinations' & here are the setup for the 2nd Workbook that I couldn't upload because of it size:

    Mega Millions Header is in A1-G1 & the DATES in Column A2 - A1781 & the winning combination numbers is in B2 - G1781. The Power Ball Header is in I1-O1 & the DATES in Column I2-I1735 & the winning combination numbers is in J2 - O1735.

    In 'VA. Lottery Combination Generator' Workbook I want a Macro to take the numbers that I picked for the Game that I want to play & generate them into Lottery combinations(Mega Millions: 1/75-1/15 or Power Ball: 1/59-1/35 & then search through the workbook 'VA. Lottery Winning Combinations' under the game that I want to play & eliminate any duplicate matches from my generated Lottery combinations so I won't be playing combination set of numbers that already been drawn before. Then list the generated combination numbers in the 'VA. Lottery Combination Generator' workbook under 'Lottery Combination Generated' worksheet under the Game Header of the game that I want to play.

    I also redone the 1st. workbook by redoing the Instructions

    I'm sorry if I made things confusing in the 1st post, I was tired & about ready to go to bed but wanna try to finish up on the 1st post that I sent.
    I hope I made things more clearer this time & any help would be appreciated.
    Attached Files Attached Files
    Last edited by studfin; 2014-06-13 at 09:43.

  4. #4
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,436
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Quote Originally Posted by studfin View Post
    so I won't be playing combination set of numbers that already been drawn before.
    And why would you want to spend time and effort to do this? Each drawing is a completely independent event and prior drawings have absolutely no effect on future drawings.

    Just my 2 cents! HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  5. #5
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts
    I agree with RG. It seems pointless to me to remove random combinations that have already been played.

    Steve

  6. #6
    New Lounger
    Join Date
    Mar 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I wanted to remove the combinations that already been played because mostly to reduce cost, beside what are the chances that a combination of numbers hitting twice when there are 258,890,850 chances for Mega Millions & 175,223,510 for Power Ball.

  7. #7
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts
    There is just as much chance as yesterday's winning number being selected as there is a chance of any other combination. The chance of any combination being hit is independent of the previous hits.

    [If I roll a 6-sided die and I get a "one", rolling it a second time will not eliminate or even reduce the odds of rolling a "one" on the second roll of that die, it remains 1 chance 6.]

    Steve

  8. #8
    New Lounger
    Join Date
    Mar 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I just wanted help with my 2 workbooks, not to be questioned about why & how it is pointless it is to have them.

  9. #9
    Gold Lounger Maudibe's Avatar
    Join Date
    Aug 2010
    Location
    Pa, USA
    Posts
    2,639
    Thanks
    115
    Thanked 650 Times in 592 Posts
    Studfin,

    Although the other posters are correct about probability odds, I understand what you are trying to do. Here is your workbook completed. I have made some modifications that I hope will make it flow much easier. The VA lottery Winning Combinations workbook had 6 columns for both the Mega Millions and PowerBall where the 6th column appears to be the Mega ball or Power ball for both (column G, column O respectively). That left a missing column for the 6th winning number. So I improvised by adding a 6th column and generated a 6th winning number. Also, the winning numbers for PowerBall were not in order so I wrote a sorting routine to clean them up. In addition, the number of columns for generated numbers were 5 in your generated numbers sheet.

    Here are the changes I made:

    1. Choosing the game using the optionbuttons modifies the grid by enabling the numbers that can be played for that game
    1. Enter the number of your choice picks into the grid by clicking the number. It will highlight in yellow. Deselect it by clicking it again.
    2. I incorporated the VA lottery Winning Combinations as a sheet into the VA Lottery Combination Generator Workbook. I temporarily did this to make the programming easier but as I worked with it, it made sense to keep it that way. If you want to separate them, it can be done.
    3. Added counters so you can track your number of selected picks and the number of generated combinations
    4. Added links to the VA Lottery web site along with tables that indicate the ways to win for easy reference.
    5. Clicking the Generate Combinations button generates all the different combinations for the picks that your selected.
    6. An automated comparison will check against previously won numbers listed on the incorporated VA Lottery Winning Numbers sheet. If a match is found, the generated duplicate will be highlighted in yellow. (see image)
    7. It wasn't clear what you wanted to do with the Mega or Power ball (7th ball). I has started to write it into the code but then figured you were not using it in your combinations any way so I just left it as is.
    8. Added a Reset button to clear all fields
    8. Since the writing of this, I have corrected some spelling errors (winng ==> winning)

    Here is a screenshot of what it looks like
    Lottery1.png

    The file is 1.45Mb and I cannot upload it. If you are interested, Private Message me and I will email it to you.

    Maud

  10. #10
    Gold Lounger Maudibe's Avatar
    Join Date
    Aug 2010
    Location
    Pa, USA
    Posts
    2,639
    Thanks
    115
    Thanked 650 Times in 592 Posts
    Studfin,

    Thanks for the email. I sent you the file for your review.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •