|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
蓝无领 发表于 2013-12-19 20:56
测试过,非常感谢赵版的帮助。
另外,想问一下,有办法自动加边框吗? - Sub Macro1()
- Dim arr, brr, sh As Worksheet, d As Object, k, t, a, i&, j&, m&, l&, s$
- 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
- On Error Resume Next
- With Worksheets
- For i = 0 To d.Count - 1
- m = 1
- a = Split(t(i), ",")
- For j = 1 To UBound(a)
- m = m + 1
- brr(m, 1) = j
- For l = 2 To UBound(arr, 2)
- brr(m, l) = arr(a(j), l)
- Next
- Next
- Set sh = .Item(k(i))
- If sh Is Nothing Then '该工作表不存在则插入一个空工作表
- .Add(Before:=.Item(.Count)).Name = k(i)
- ActiveSheet.[a1].Resize(m, l - 1) = brr
- ActiveSheet.[a1].Resize(m, l - 1).Borders.LineStyle = xlContinuous
- Else
- sh.Cells.Clear
- sh.[a1].Resize(m, l - 1) = brr
- sh.[a1].Resize(m, l - 1).Borders.LineStyle = xlContinuous
- Set sh = Nothing
- End If
- Next
- End With
- Application.ScreenUpdating = True
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|