Results 1 to 7 of 7

Thread: Excel Maximum Rows

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,888
    Location
    To me the macros seemed more complicated that they had to be

    This is another way


    Option Explicit
    
    
    Sub GenerateCombo()
        Dim r As Range
        Dim v As Variant
        Dim n1 As Long, n2 As Long, n3 As Long, n4 As Long, n5 As Long
        Dim rowCount As Long, colCount As Long
        Dim N As Long
        
        With ActiveSheet
            Set r = .Range("A1")
            Set r = Range(r, r.End(xlDown))
            
            v = Application.WorksheetFunction.Transpose(r)
            N = UBound(v)
            
            rowCount = 1
            colCount = 3
            
            For n1 = 1 To N - 4
                For n2 = n1 + 1 To N - 3
                    For n3 = n2 + 1 To N - 2
                        For n4 = n3 + 1 To N - 1
                            For n5 = n4 + 1 To N
                                .Cells(rowCount, colCount).Value = v(n1) & "," & v(n2) & "," & v(n3) & "," & v(n4) & "," & v(n5)
                                rowCount = rowCount + 1
                                If rowCount = 100001 Then
                                    rowCount = 1
                                    colCount = colCount + 1
                                    Application.StatusBar = v(n1) & "," & v(n2) & "," & v(n3) & "," & v(n4) & "," & v(n5)
                                    DoEvents
                                End If
                            Next n5
                        Next n4
                    Next n3
                Next n2
            Next n1
        End With
        
        Application.StatusBar = False
        
        MsgBox "Done"
        
    End Sub
    Attached Files Attached Files
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Tags for this Thread

Posting Permissions

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