|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub 生成分表()
- Dim d, k, arr, brr(), sht
- Dim i&, r%, MMyr%, n%, j%, m%, b%
- Dim shp As Shape
- Application.DisplayAlerts = Flase '关闭系统提示
- Set d = CreateObject("Scripting.Dictionary")
- Set sht = Sheet1
- Myr = sht.[a65536].End(xlUp).Row
- arr = sht.Range("a2:j" & Myr)
- ReDim brr(1 To 500, 1 To 9)
- For i = 1 To UBound(arr)
- d(arr(i, 4)) = ""
- Next
- 删除分表
- For Each k In d.keys
- m = m + 1
- For i = 1 To UBound(arr)
- If arr(i, 4) = k Then
- n = n + 1
- For j = 1 To 3
- brr(n, j) = arr(i, j)
- Next
- For j2 = 4 To 9
- brr(n, j2) = arr(i, j + 1)
- Next
- End If
- Next
- Worksheets("模板").Copy after:=Worksheets(Worksheets.Count)
- On Error Resume Next
- With ActiveSheet
- .Range("A3:J500").Borders.LineStyle = xlNone
- .Range("A3").Resize(n, 9) = brr
- .Range("B1") = k
- .Name = k
- With .Range("A2").Resize(n + 1, 9)
- 'With Range("a9:h" & 10 + n)
- .Borders.LineStyle = xlContinuous '添总体加边框线
- .BorderAround xlContinuous, xlMedium '外边框加粗
- .Font.Size = 10 '字体10号
- End With
- End With
- n = 0
- Next
- Sheets("UFPrn20180908102329").Activate
- Application.DisplayAlerts = True '系统提示
- End Sub
-
- Sub 删除分表()
- Application.DisplayAlerts = False
- For Each sh In Worksheets
- If sh.Name <> "UFPrn20180908102329" And sh.Name <> "模板" Then sh.Delete
- Next
- Application.DisplayAlerts = True
- End Sub
复制代码 |
|