|
参与一下。。。
- Sub ykcbf() '//2024.5.25 查询
- Dim wb, arr, sh
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set d = CreateObject("Scripting.Dictionary")
- Set sh = ThisWorkbook.Sheets("数据源")
- arr = sh.UsedRange
- bt = 1 '//标题行数
- col = 1 '//列号
- For i = bt + 1 To UBound(arr)
- s = arr(i, col)
- If Not d.exists(s) Then Set d(s) = CreateObject("Scripting.Dictionary")
- d(s)(i) = Application.Index(arr, i)
- Next
- ReDim brr(1 To UBound(arr), 1 To UBound(arr, 2))
- With Sheets("结果")
- st = .[b2].Value
- For Each k In d.keys
- If st = k Then
- For Each kk In d(k).keys
- m = m + 1
- For j = 1 To UBound(arr, 2)
- brr(m, j) = arr(kk, j)
- Next
- Next
- End If
- Next
- .[a4:d1000] = ""
- .[a4].Resize(m, UBound(arr, 2)) = brr
- End With
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|