|
- <div>
- </div><div>Sub dataToactionlist()
- </div> Dim arr1()
- Dim x, i, j As Integer
- Sheets("project").Select
- x = Range("J65536").End(xlUp).Row
- j = 1
- For i = 1 To x
- ReDim Preserve arr1(1 To j, 1 To 6)
- If Cells(i + 3, 10) = "High" Or Cells(i + 3, 10) = "Key" Or Cells(i + 3, 10) = "联络/跟踪" Then
- arr1(j, 1) = Cells(i + 3, 3).Text
- arr1(j, 2) = Cells(i + 3, 9).Text
- arr1(j, 3) = Cells(i + 3, 10).Text
- arr1(j, 4) = Cells(i + 3, 11).Text
- arr1(j, 5) = Cells(i + 3, 12).Text
- arr1(j, 6) = Cells(i + 3, 13).Text
- j = j + 1
- End If
- Next i
- End Sub
复制代码 老师们好,在我定义一个动态二维数组,已知使用到的列为6列,但是行我希望满足条件才加进去,代码运行时ReDim Preserve arr1(1 To j, 1 To 6)报错,我该怎么样去定义这个已知为6列的数组二维数组呢?
本帖最后由 我行我速2008 于 2022-8-17 11:08 编辑
ReDim Preserve 时变量只能出现于数组的最后一维。
不能:
ReDim Preserve arr1(1 To j, 1 To 6)
只能ReDim Preserve arr1(1 To 6, 1 To j)
|
|