|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 lmlovely 于 2015-5-21 00:36 编辑
各位大侠,小女子在工作表的拆分上已照样画葫芦会了皮毛,但拆分好了之后发现数据的一些格式发生了变化,边框没有设置,这个问题如何在代码中修改?谢谢各位,复制代码如下:请赐教!
Sub fj()
Dim d As Object, i&, k&, r&, ar, arr
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set d = CreateObject("scripting.dictionary")
For Each sh In Sheets
If sh.Name <> "sheet1" Then sh.Delete
Next
With Sheets("sheet1")
ar = .Range("a2:p" & .[a65536].End(3).Row)
ReDim arr(1 To UBound(ar), 1 To UBound(ar, 2))
End With
brr = Array("组别", "序号", "1起", "1止", "2起", "2止", "地点")
For i = 1 To UBound(ar)
d(ar(i, 1)) = ""
Next
m = d.keys
For n = 0 To d.Count - 1
k = 0
With Worksheets.Add(after:=Sheets(Sheets.Count))
.Name = m(n)
For i = 1 To UBound(ar)
If ar(i, 1) = m(n) Then
k = k + 1
For r = 1 To UBound(ar, 2)
arr(k, r) = ar(i, r)
Next
End If
Next
.[a1].Resize(1, 8) = brr
.[a2].Resize(k, UBound(ar, 2)) = arr
End With
Next
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Set d = Nothing
End Sub
|
|