|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub test()
- Dim r%, i%, m%
- Dim arr, brr(1 To 1000, 1 To 2)
- Dim d As Object
- Set d = CreateObject("scripting.dictionary")
- Set d1 = CreateObject("scripting.dictionary")
- With Worksheets("sheet2")
- r = .UsedRange.Find(what:="*", LookIn:=xlValues, lookat:=xlWhole, searchorder:=xlByRows, searchdirection:=xlPrevious).Row
- arr = .Range("a1:d" & r)
- For j = 1 To UBound(arr, 2)
- lx = Right(arr(1, j), 1)
- Set d(lx) = CreateObject("scripting.dictionary")
- For i = 2 To UBound(arr)
- If Len(arr(i, j)) <> 0 Then
- d(lx)(arr(i, j)) = ""
- End If
- Next
- Next
- End With
- With Worksheets("sheet1")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a2:d" & r)
- For i = 1 To UBound(arr)
- If Not d1.exists(arr(i, 2)) Then
- Set d1(arr(i, 2)) = CreateObject("scripting.dictionary")
- d1(arr(i, 2))(1) = arr(i, 1)
- Set d1(arr(i, 2))(2) = CreateObject("scripting.dictionary")
- End If
- d1(arr(i, 2))(2)(arr(i, 3)) = arr(i, 4)
- Next
- End With
- m = 0
- For Each aa In d1.keys
- lx = d1(aa)(1)
- For Each bb In d(lx).keys
- If d1(aa)(2).exists(bb) Then
- If d1(aa)(2)(bb) < 60 Then
- m = m + 1
- brr(m, 1) = aa
- brr(m, 2) = bb
- End If
- Else
- m = m + 1
- brr(m, 1) = aa
- brr(m, 2) = bb
- End If
- Next
- Next
- With Worksheets("sheet3")
- .UsedRange.Offset(1, 0).ClearContents
- .Columns(1).NumberFormatLocal = "@"
- .Range("a2").Resize(m, UBound(brr, 2)) = brr
- End With
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|