請問
為何以下的陣列是固定陣列?
With Sheets("1")
rng = .Range(.[c10], .[m83].End(3))
End With
ReDim arr(1 To UBound(rng), 1 To 10)
For i = 1 To UBound(rng)
If rng(i, 11) - rng(i, 10) <> 0 Then
k = k + 1
For j = 1 To 6
arr(k, j) = rng(i, j)
Next
arr(k, 8) = rng(i, 8) - rng(i, 6)
arr(k, 9) = arr(k, 8) - arr(k, 6)
arr(k, 10) = rng(i, 11) + rng(i, 10)
End If
Next
以下為何是變動陣列
a = Sheets("1").[c10].CurrentRegion
r = 1
For i = 1 To UBound(a)
ReDim Preserve arr(1 To 3, 1 To r)
arr(1, r) = a(i, 1): arr(2, r) = a(i, 2): arr(3, r) = a(i, 3)
r = r + 6
Next作者: oobird 時間: 2010-9-7 20:05
ReDim arr(1 To UBound(rng), 1 To 10)
如ubound(rng)為100
其結果為arr(1 to 100,1 to 10)
當屬固定陣列。
r = 1
For i = 1 To UBound(a)
ReDim Preserve arr(1 To 3, 1 To r)
arr(1, r) = a(i, 1): arr(2, r) = a(i, 2): arr(3, r) = a(i, 3)
r = r + 6
next
第一個i循環時r=1,arr(1 To 3, 1 To r)=arr(1 to 3,1 to 1)
第2個i循環時r=7,arr(1 To 3, 1 To r)=arr(1 to 3,1 to 7)
第3個i循環時r=13,arr(1 To 3, 1 To r)=arr(1 to 3,1 to 13)
這樣就叫動態陣列。作者: Hsieh 時間: 2010-9-7 20:08
For c = 4 To items + of
i = 1
a = 0
For Each CK In ActiveSheet.OLEObjects '1 next
If CK.Name Like "CheckBox*" Then '2 end 判斷checkbox
If CK.Object.Value = True Then '3 end 判斷true/false
If q > 1 Then
Myarray(0, a) = Cells(3, i)
Myarray(1, a) = Cells(c, i)
a = a + 1
End If
End If
i = i + 1
End If
Next
Csvgo.writetext Myarray(0, 0) & "," & Myarray(0, 1) & vbCrLf & Myarray(1, 0) & "," & Myarray(1, 1) & vbCrLf
Next c