|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Option Explicit
- Sub test0() '
- Dim dict As Object, wks As Worksheet
- Dim data, i As Long, j As Long, strKey As String
- Dim titleRow As Long
- titleRow = 1 '标题所在 行
- DoApp False
- Worksheets("总").Activate
- For Each wks In Worksheets
- If wks.Name <> ActiveSheet.Name Then wks.Delete
- Next
- Set dict = CreateObject("Scripting.DictionAry")
- With Range("A1").CurrentRegion
- j = .Columns.Count
- data = .Value
- End With
- For i = titleRow + 1 To UBound(data)
- strKey = data(i, 3) & "|" & data(i, 5)
- If Len(strKey) Then
- If Not dict.Exists(strKey) Then Set dict(strKey) = Range("A1").Resize(titleRow, j)
- Set dict(strKey) = Union(dict(strKey), Range("A" & i).Resize(1, j))
- End If
- Next
- For i = 0 To dict.Count - 1
- With Worksheets.Add(After:=Worksheets(Worksheets.Count))
- .Name = Replace(dict.Keys()(i), "|", "")
- dict.Items()(i).Copy .Range("A1")
- .Columns.AutoFit
- End With
- Next
- Worksheets(1).Activate
- Set dict = Nothing
- DoApp
- Beep
- End Sub
- Function DoApp(Optional b As Boolean = True)
- With Application
- .ScreenUpdating = b
- .DisplayAlerts = b
- .Calculation = -b * 30 - 4135
- End With
- End Function
复制代码 |
评分
-
1
查看全部评分
-
|