Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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; Code: -------------------- 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; Code: -------------------- For r = 0 To aryCount p = 1 q = 0 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 q = q + 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 -- gti_jobert ------------------------------------------------------------------------ gti_jobert's Profile: http://www.excelforum.com/member.php...o&userid=30634 View this thread: http://www.excelforum.com/showthread...hreadid=508000 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to write an array to a range without looping | Excel Worksheet Functions | |||
Simple Array Looping | Excel Programming | |||
Array / Looping Question | Excel Programming | |||
Error after last object in the array when looping For...each | Excel Programming | |||
Looping through Sheets and passing values to an Array | Excel Programming |