0
是否相信我已經搜索谷歌,堆棧,MSDN並查看了無數的示例代碼,給出了各種數組的示例。我可以得到簡單的數組來處理For ... Next循環;如下所示,但無論如何構造下面的代碼,我都無法獲得輸出以反映每個代碼在每個數組之間來回切換,每次一個變量。有什麼想法嗎。我需要在數組中創建一個數組嗎?鋸齒陣列?我研究過多維數組,他們似乎可能是正確的方法。但是,我不確定。兩個數組之間的交替輸出
好吧,現在downvote和消散! -_-
Sub Array 123()
Dim myarray As Variant
Dim myarray2 As Variant
'Let's assume ranges a1, a2 and a3 contain values 1, 2 and 3 and that
'ranges a4, a5 and a6 contain values 4, 5 and 6
myarray = ThisWorkbook.Worksheets("sheet6").Range("a1:a3").Value
myarray2 = ThisWorkbook.Worksheets("sheet6").Range("a4:a6").Value
For i = 1 To UBound(myarray)
MsgBox myarray(i, 1)
Next i
For j = 1 To UBound(myarray2)
MsgBox myarray2(j, 1)
Next j
End Sub
'the out put will be:
[ 1 2 3 4 5 6 ]
'how would one arrange the structure of the code above so that the output is:
[ 1 4 2 5 3 6 ]
這完美地工作。謝謝! Upvoted和接受! :) – Singularity20XX