|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub qs()
- Dim arr, i, dic
- Set dic = CreateObject("scripting.dictionary")
- arr = Sheet1.UsedRange.Value
- For i = 2 To UBound(arr)
- s = arr(i, 1)
- t = arr(i, 2) & "," & arr(i, 3) & "," & arr(i, 4) & "," & arr(i, 5)
- If Not dic.exists(s) Then
- dic(s) = t
- Else
- dic(s) = dic(s) & "|" & t
- End If
- Next
- Application.ScreenUpdating = False: Application.DisplayAlerts = False
- For Each k In dic.keys
- Sheet2.Copy
- With ActiveWorkbook
- .Sheets("模板").Range("a2:e1000") = ""
- ss = Split(dic(k), "|")
- ReDim brr(1 To UBound(ss) + 1, 1 To 5)
- m = 0
- For Each s In ss
- m = m + 1
- brr(m, 1) = k
- xx = Split(s, ",")
- For y = 0 To UBound(xx)
- brr(m, y + 2) = xx(y)
- Next
- Next
- .Sheets("模板").Range("a2").Resize(m, 5) = brr
- .SaveAs ThisWorkbook.Path & "" & k
- .Close False
- End With
- Next
- Application.ScreenUpdating = True: Application.DisplayAlerts = True
- End Sub
复制代码 |
|