Welcome Guest
Log In | Register )
You last visited January 24, 2017, 8:11 am
All times shown are
Eastern Time (GMT-5:00)

Combination Vba

Topic closed. 5 replies. Last post 13 years ago by lottoarchitect.

Page 1 of 1
PrintE-mailLink
Avatar
New Member
Szombathely
Hungary
Member #4363
April 16, 2004
2 Posts
Offline
Posted: April 16, 2004, 5:45 pm - IP Logged

Hello  Lotto Masters !

Please sorry for my bad english ... i am from Europe , Hungary , Szombathely. I speek only Hungarian and German acceptable. Also i have a problem, i want calculate the lotto numbers from a combination number . Exampl.  1 = 1,2,3,4,5,6  and  the 8.145.060 = 40,41,42,43,44,45 , also the last possible combination. I have MS Excel, and want write a VBA - Macro for calculating the real lotto numbers from the Combination number.  PLEASE HELP ME ! You are Masters of Lotto , and VBA !  Thanks , and Good Look !

    hypersoniq's avatar - 8ball
    Pennsylvania
    United States
    Member #1340
    April 6, 2003
    2450 Posts
    Offline
    Posted: April 16, 2004, 8:57 pm - IP Logged

    I adapted this from another forum as originally presented by Gilles D.

    This is a vba program that will list all combos, provided it doesn't run out of mempry or cell address spaces...

    Instructions per Gilles D...

    1 - Open a worksheet and then a module in VBA (Alt-F11)
    2 - Cut and paste the program I posted into that module
    3 - Go back to the worksheet and start the program List_Comb
    4 - Wait a few minutes (less than 2 on mine) and you will get all 165,772 combinations in columns A, B and C. <<< here is where your version will take alot longer and use more columns...

    Here is your modified program... use autofit to arrange the data for viewing after it's done... it WILL overlap....

    CUT BELOW THIS LINE....

    Option Explicit

    Dim A As Integer, B As Integer, C As Integer
    Dim D As Integer, E As Integer, F As Integer
    Dim N As Long

    Sub List_Comb()
    Range("A1").Select
    Application.ScreenUpdating = False
    N = 0
    For A = 1 To 40
    For B = A + 1 To 41
    For C = B + 1 To 42
    For D = C + 1 To 43
    For E = D + 1 To 44
    For F = E + 1 To 45
    ActiveCell.Value = A & "-" & B & "-" & C & "-" & D & "-" & E & "-" & F
    ActiveCell.Offset(1, 0).Select
    N = N + 1
    If N = 65001 Then
    N = 0
    ActiveCell.Offset(-65001, 1).Select
    Application.ScreenUpdating = True
    Application.ScreenUpdating = False
    End If
    Next F
    Next E
    Next D
    Next C
    Next B
    Next A
    Application.ScreenUpdating = True
    End Sub

    CUT ABOVE THIS LINE

    Good Luck and welcome to Lottery Post!

    Playing more than one ticket per game is betting against yourself.

      hypersoniq's avatar - 8ball
      Pennsylvania
      United States
      Member #1340
      April 6, 2003
      2450 Posts
      Offline
      Posted: April 16, 2004, 8:58 pm - IP Logged

      the value for N is the max value of rows for excel, without that, you get assorted range errors...

      Playing more than one ticket per game is betting against yourself.

        Avatar
        New Member
        Szombathely
        Hungary
        Member #4363
        April 16, 2004
        2 Posts
        Offline
        Posted: April 17, 2004, 3:14 am - IP Logged

        Hi !

        Ok , it s not bad you macro, but i need dynamically funktion. So i want exampl. to calculate the lotto numbers ( 6 from 45 ) of the 1.245.082 , i must to run the completely mackro from 1.....to...1.245.082 , and the last line its the result. This take memory and porcessor speed. Only the funktion it s okay, but i want to build into my spreadset and this is a big 9Mb excel database with filter and, other functions to search the top random numbers. Sorry, it is too slow for me, i need a dynamically working vba makro. Thanx,  Good Bye !


          Australia
          Member #3084
          December 22, 2003
          328 Posts
          Offline
          Posted: April 17, 2004, 11:13 pm - IP Logged

          Vba-Kid

          I like your alias (Aussies are masters of the understatement.).

          Your problem is a bit hard to fathom out as I think we are losing something in the translation. Having read quite a few times what you are asking the best I can come up with is for a given Combination (what you refer to as an Index) and the position of that Combination in the order of how the combinations were enumerated you want to know which numbers have to that point been included.

          If my interpretation is correct then I make two points to you.
                                          1 You need to have a basic understanding of probability
                                              if you want to develop some Lotto System.
                                          2 Following from that the order in which you have
                                            enumerated your combinations which usually has some
                                            relationship to Mathematical Order has no more
                                             significance than the billions of other Orders.

          However, I have an open mind and what you're doing is so bizare as to be interesting. Don't take any offence from this - I have tried many bizare calculations myself. Sometimes in the process of doing one thing you get an idea for another thing.

          Regards

          Colin F
                                              of the Billions of other Orders

            lottoarchitect's avatar - waveform

            Greece
            Member #2815
            November 18, 2003
            502 Posts
            Offline
            Posted: April 18, 2004, 6:43 pm - IP Logged

            Hi VBA-kid, I've posted a long time ago a very good code to dynamically convert lotteries. Here is the link "Lottery SPAN style=COLOR: #000000; BACKGROUND-COLOR: #ffff66>combo/SPAN Question". It is much simpler than the above code you post but it is not in VBA. Hope you find it useful.

            If you have something to do, at least do it well...