|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub Macro1()
- Dim arr, brr, sh As Worksheet, d As Object, k, t, a, i&, j&, m&, l&
- Application.ScreenUpdating = False
- Set d = CreateObject("scripting.dictionary")
- arr = [a1].CurrentRegion
- For i = 2 To UBound(arr)
- d(arr(i, 9)) = d(arr(i, 9)) & "," & i
- Next
- k = d.Keys
- t = d.Items
- brr = arr
- d.RemoveAll
- For Each sh In Sheets
- d(sh.Name) = ""
- Next
- With Sheets
- For i = 0 To UBound(k)
- m = 1
- a = Split(t(i), ",")
- For j = 1 To UBound(a)
- m = m + 1
- For l = 1 To UBound(arr, 2)
- brr(m, l) = arr(a(j), l)
- Next
- Next
- If Not d.Exists("" & k(i)) Then
- .Add After:=.Item(.Count)
- ActiveSheet.Name = k(i)
- Else
- Sheets("" & k(i)).Cells.Clear
- End If
- Sheets("" & k(i)).[a1].Resize(m, UBound(brr, 2)) = brr
- Next
- End With
- Application.ScreenUpdating = True
- Sheets("总表").Select
- End Sub
复制代码 我淘来的,一直捂在箱底没舍得扔 |
|