title: excel vba permutations exceed 1048576 rows
body: <p>I'm trying to create a permutation list in excel for 6 numbers, each in their own columnA-F and each number is from 1-38. when i run the VBA i find that the permutations far exceed rows 1048576 available in excel, so therefore the VBA ends at that point. i want a VBA that when the rows reach 1048576 on whatever sheet and the permutation isnt finished it will just create a new sheet and continue where it stopped on the previous sheet and automatically create sheets until the permutation ends. i've searched passed questions but none found to help. Any expert help would be greatly appreciated.</p>
  
  <p>Code:</p>
  
  <pre><code>   Sub Perm()
  
     Dim a As Integer
     Dim b As Integer
     Dim c As Integer
     Dim d As Integer
     Dim e As Integer
     Dim f As Integer
  
      n = 1
  
  For a = 1 To 38
  For b = 1 To 38
      For c = 1 To 38
          For d = 1 To 38
              For e = 1 To 38
                  For f = 1 To 38
  Cells(n, 1).Value = a
          Cells(n, 2).Value = b
                  Cells(n, 3).Value = c
                          Cells(n, 4).Value = d
                                  Cells(n, 5).Value = e
                                          Cells(n, 6).Value = f
  
                  n = n + 1
  
  
                  Next f
              Next e
          Next d
        Next c
      Next b
    Next a
  
   End Sub
  </code></pre>