|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 按照实际内容拆分并保留标题()
Application.ScreenUpdating = False
Set d = CreateObject("scripting.dictionary")
arr = Sheets(1).UsedRange
For j = 2 To UBound(arr)
If d.exists(arr(j, 2)) Then
Set d(arr(j, 2)) = Union(d(arr(j, 2)), Cells(j, 1))
Else
Set d(arr(j, 2)) = Union([a1], Cells(j, 1))
End If
Next j
For j = 0 To d.Count - 1
Sheets.Add after:=Sheets(Sheets.Count)
Sheets(Sheets.Count).Name = d.keys()(j)
d.items()(j).EntireRow.Copy Sheets(Sheets.Count).[a1]
Next j
Application.ScreenUpdating = True
End Sub
|
-
1
-
2
|