UnsolvedCoding
Technical User
Can anyone tell me why the code below will produce incorrect results?
Code:
For A = 0 To COUNTER
ReDim Preserve IO_Array(D)
IO_Array(D) = Sheets("io" & Temp_Nmbr).Cells(B, C).Value
D = D + 1
ReDim Preserve IO_Array(D)
IO_Array(D) = Sheets("io" & Temp_Nmbr).Cells(B, C + 3).Value
Debug.Print IO_Array(D - 1) & " " & IO_Array(D)
B = B + 1
D = D + 1
Next A
D = 0
B = 1
C = 1
For A = 0 To COUNTER
Sheets("Sheet1").Cells(B, C).Value = IO_Array(D)
Debug.Print IO_Array(D)
D = D + 1
Sheets("Sheet1").Cells(B, C + 1).Value = IO_Array(D)
Debug.Print IO_Array(D)
Debug.Print IO_Array(D - 1) & " " & IO_Array(D)
D = D + 1
B = B + 1
Next A
Original List......Resulting list
V........................V
V........................V
V........................V
V........................V
V........................V
V........................V
LV.......................LV
LV.......................LV
PL.......................LV
DO.......................LV
DO.......................PL
DO.......................DO
Code:
For A = 0 To COUNTER
ReDim Preserve IO_Array(D)
IO_Array(D) = Sheets("io" & Temp_Nmbr).Cells(B, C).Value
D = D + 1
ReDim Preserve IO_Array(D)
IO_Array(D) = Sheets("io" & Temp_Nmbr).Cells(B, C + 3).Value
Debug.Print IO_Array(D - 1) & " " & IO_Array(D)
B = B + 1
D = D + 1
Next A
D = 0
B = 1
C = 1
For A = 0 To COUNTER
Sheets("Sheet1").Cells(B, C).Value = IO_Array(D)
Debug.Print IO_Array(D)
D = D + 1
Sheets("Sheet1").Cells(B, C + 1).Value = IO_Array(D)
Debug.Print IO_Array(D)
Debug.Print IO_Array(D - 1) & " " & IO_Array(D)
D = D + 1
B = B + 1
Next A
Original List......Resulting list
V........................V
V........................V
V........................V
V........................V
V........................V
V........................V
LV.......................LV
LV.......................LV
PL.......................LV
DO.......................LV
DO.......................PL
DO.......................DO