Jacklovely

导航

 

说明(2017.3.25):

1. 知识点为dim arr2(1 to 1000, 1 to 4)先定义一个足够大的二维数组,不然后面需要transpose转置成一维数组。

 1 '抽取列表中叫“虹虹”的所有信息,设置arr2数组1到1000,可以省略转置步骤
 2 Public Sub test1()
 3     Dim arr, arr2(1 To 1000, 1 To 4), k
 4     arr = Range("a1:d5")
 5 '    MsgBox (UBound(arr))
 6 '    Stop
 7     For i = 1 To UBound(arr, 1)
 8         If arr(i, 1) = "虹虹" Then
 9             k = k + 1
10             arr2(k, 1) = arr(i, 1)
11             arr2(k, 2) = arr(i, 2)
12             arr2(k, 3) = arr(i, 3)
13             arr2(k, 4) = arr(i, 4)
14             Cells(i, 5) = "这个"
15         End If
16     Next
17     Range("a" & (2 + i)).Resize(k, 4) = arr2
18 End Sub

 

posted on 2017-03-25 17:40  Jacklovely  阅读(462)  评论(0编辑  收藏  举报