|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub qs() '2024\09\19
- Dim arr, i, dic, sht As Worksheet
- Set dic = CreateObject("scripting.dictionary")
- ReDim brr(1 To 50000, 1 To 4): crr = [{"日期","备注","文件名称","列号"}]
- For Each sht In Sheets
- If sht.Name <> "重复信息" Then
- cl = sht.Cells(9, Columns.Count).End(xlToLeft).Column
- arr = sht.Range(sht.Cells(9, 1), sht.Cells(10, cl))
- For c = 2 To UBound(arr, 2)
- s = arr(2, c)
- If Not dic.exists(s) Then
- dic(s) = arr(1, c) & "'" & arr(2, c) & "'" & sht.Name & "'" & c
- Else
- dic(s) = dic(s) & "|" & arr(1, c) & "'" & arr(2, c) & "'" & sht.Name & "'" & c
- End If
- Next c
- End If
- Next sht
- For Each k In dic.keys
- kk = Split(dic(k), "|")
- If UBound(kk) > 0 Then
- For i = 0 To UBound(kk)
- m = m + 1
- kkk = Split(kk(i), "'")
- For j = 0 To UBound(kkk)
- brr(m, j + 1) = kkk(j)
- Next
- Next
-
- End If
- Next
- With Sheet3
- .Cells.Clear
- .Range("a1").Resize(1, 4) = crr
- .Range("a2").Resize(m, 4) = brr
- .ListObjects.Add xlSrcRange, .[a1].CurrentRegion, , xlYes
- End With
- End Sub
复制代码 |
|