+ Reply to Thread
Results 1 to 1 of 1

Nested loops VBA

Hybrid View

  1. #1
    Registered User
    Join Date
    11-28-2011
    Location
    zurich, CH
    MS-Off Ver
    Excel 2003
    Posts
    11

    Nested loops VBA

    Somehow managed to sort this myself.
    Posting the code, should it be of interest to anyone.
    Cheers, n
    Sub VBA_short()
    *
    Dim D1, D2 As Date***
    Dim tempoimpiegato As String*
    D1 = Time**
    *
    *** Dim myarray As Variant
    *** Dim myarraysev(1000000#) As Variant
    *** Dim bigArray(1000000#) As Variant
    *** Dim sum As Double
    *** Dim smallarray(1 To 50000, 2) As Variant
    ******
    *** Dim x As Long, j As Long, n As Long, i As Long
    *******
    *** myarray = Worksheets("Sheet1").Range("A1:cv20000").Value
    *
    *** ****For x = 1 To 20000
    *
    ******* For j = 1 To 50
    *
    sum = 0
    ***********************************
    *********** *********** For n = 1 To myarray(x, j)
    ***********
    *********** *********** myarraysev(n) = Application.WorksheetFunction.LogInv(Rnd(), 6.2146, 1.3204)
    **************************************************
    *********** *********** sum = myarraysev(n) + sum
    *****************************************************
    *********** *********** Next n
    ***********
    *********** i = i + 1
    *******************************
    ********** bigArray(i) = sum
    ***********
    ******* Next j
    *
    *** Next x
    ***
    *
    For col = 1 To 25
    *
    smallcounter = 1
    *
    For i = 1 + ((col - 1) * 50000) To col * 50000
    *
    smallarray(smallcounter, 0) = i
    *
    smallarray(smallcounter, 1) = bigArray(i)
    *
    smallcounter = smallcounter + 1
    *
    Next i
    *
    Range("hhhh").Resize(50000, 2).Offset(0, (col - 1) * 3).Value = smallarray
    *
    Next col
    *
    D2 = Time
    *
    tempoimpiegato = Format(D2 - D1, "hh:mm:ss")
    *
    MsgBox "Tempo impiegato: " & tempoimpiegato**
    *
    End Sub
    Last edited by zurich; 02-17-2012 at 07:02 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 6 users browsing this thread. (0 members and 6 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1