|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub test()
- Set d = CreateObject("scripting.dictionary")
- Application.ScreenUpdating = False
- Set sh = Sheets(1)
- For j = 2 To sh.Cells(2, Columns.Count).End(xlToLeft).Column
- str1 = sh.Cells(2, j)
- If d.exists(str1) Then
- Set d(str1) = Union(d(str1), sh.Columns(j))
- Else
- Set d(str1) = Union(sh.Columns(1), sh.Columns(j))
- End If
-
- Next j
- For j = 0 To d.Count - 1
- Sheets.Add after:=sh
- Sheets(2).Name = d.keys()(j)
- d.items()(j).Copy Sheets(2).[a1]
- Next j
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|