- Sub TestSub()
- Dim i, j, k, arr, brr, crr
- Dim dic As Object, key As String
- Set dic = CreateObject("scripting.dictionary")
- brr = Sheet2.Range("A2").CurrentRegion.Value
- arr = Sheet5.Range("A1").CurrentRegion.Value
- For i = LBound(arr) To UBound(arr)
- key = arr(i, 1)
- dic(key) = arr(i, 4)
- Next
- ReDim crr(1 To 1000, 1 To 4)
- For i = 2 To UBound(brr)
- key = brr(i, 2)
- If brr(i, 3) = "未报名" Then
- j = j + 1
- crr(j, 1) = key
- crr(j, 3) = dic(key)
- End If
- If brr(i, 3) < 6 Then
- k = k + 1
- crr(k, 2) = key
- crr(k, 4) = dic(key)
- End If
- Next
- Sheet2.Range("T2").Resize(UBound(crr), 4) = crr
- End Sub
复制代码 |