|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 测试()
Dim i%, j%, k%, m%, n%, arr, brr, s$, drr
Dim dic As Object, key, keys, items
Set dic = CreateObject("scripting.dictionary")
arr = Sheet1.Range("A1:M" & Sheet1.Cells(Rows.Count, "B").End(xlUp).Row)
For i = 2 To UBound(arr)
For j = 1 To UBound(arr, 2)
If arr(i, j) = "" Then
If InStr(arr(i, 13) & "语数英", Left(arr(1, j), 1)) > 0 Then
key = arr(i, 1) & "," & arr(i, 2) & "," & arr(i, 3)
s = s & "," & arr(1, j)
dic(key) = s
End If
End If
Next
s = ""
Next
keys = dic.keys
ReDim brr(1 To dic.Count + 1, 1 To 4)
brr(1, 1) = "班级": brr(1, 2) = "缺考考号"
brr(1, 3) = "缺考姓名": brr(1, 4) = "科目"
For i = LBound(keys) To UBound(keys)
key = keys(i)
brr(2 + i, 1) = Split(key, ",")(0)
brr(2 + i, 2) = Split(key, ",")(1)
brr(2 + i, 3) = Split(key, ",")(2)
brr(2 + i, 4) = Mid(dic.items()(i), 2)
Next
Sheet1.Range("O1").Resize(dic.Count + 1, 4) = brr
End Sub |
|