Results 1 to 1 of 1

Looping data out of array

Threaded View

  1. #1
    Forum Contributor
    Join Date
    01-19-2006
    Posts
    142

    Looping data out of array

    Hi all,

    the code below, loops data from my userform into an array, I have posted this on here before but am going to elaborate a little more in this thread;

    Static Counter As Long
                Static sizeofarray As Long
                
                Counter = Counter + 1
                ReDim Preserve ary(1 To 3, 1 To 3, 1 To Counter)
                
                flag = False
                
                For i = 1 To 3
                
                        ary(1, i, Counter) = MachineNumber
                        ary(2, i, Counter) = Controls("lblDTCode" & i).Caption
                        ary(3, i, Counter) = Controls("lblDTDuration" & i).Caption
                        
                        If ary(2, i, Counter) <> "" Then
                        
                            sizeofarray = sizeofarray + 1
                            aryCount = sizeofarray
                        
                        End If
                        
                        flag = True
                     
                Next i
    As stated in previous post, the code above works fine, looping it back out is the problem;

    For r = 0 To aryCount
                    
                        p = 1
                        Do
                            
                            If ary(2, p, i) <> "" Then
                
                                ActiveCell.Offset(r, 6) = ary(2, p, i)
                                ActiveCell.Offset(r, 7) = ary(3, p, i)
                            
                            End If
                        
                        p = p + 1
                        Loop Until p = 4
            
                    Next r
    It seems I need a nested loop for 3 variables (i, r, and p) where i loops through 1-6, r loops through 0-18 and p loops through 1-3. Anyone out there got any clue?

    I am going to stick with a 3d array btw, seems the most appropriate for the data. Thanks all
    Last edited by gti_jobert; 02-03-2006 at 06:22 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 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