|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub lqxs()
- Dim Arr, i&, Sht As Worksheet, j&, aa, c%, zh$, y&, h
- Dim d, k, t
- Set d = CreateObject("Scripting.Dictionary")
- Application.ScreenUpdating = False
- Sheet4.Activate
- gcmc = [b1].Value: sgdw = [b2].Value: xmjl = [b3].Value: fbmc = [b4].Value
- h = Array(20, 23, 24, 28, 29)
- Myr = [a65536].End(xlUp).Row
- Arr = Range("a7:j" & Myr)
- For i = 1 To UBound(Arr)
- d(Arr(i, 1)) = d(Arr(i, 1)) & i & ","
- Next
- k = d.keys
- t = d.items
- For i = 0 To UBound(k)
- Sheets("分表模板").Copy after:=Sheets(Sheets.Count)
- Set Sht = ActiveSheet
- Sht.Name = "第" & k(i) & "页"
- t(i) = Left(t(i), Len(t(i)) - 1)
- With Sht
- .[f5] = gcmc
- .[e7] = sgdw
- .[f6] = fbmc
- .[u7] = xmjl: c = 6: zh = ""
- If k(i) < 10 Then
- .[u3] = k(i)
- Else
- .[s3] = Left(k(i), 1)
- .[u3] = Right(k(i), 1)
- End If
- If InStr(t(i), ",") Then
- aa = Split(t(i), ",")
- For j = 0 To UBound(aa)
- c = c + 1: zh = zh & Arr(aa(j), 2) & "#、"
- For y = 4 To 8
- .Cells(h(y - 4), c) = Arr(aa(j), y)
- Next
- Next
- .[r32] = Arr(aa(0), 3)
- .[r35] = Arr(aa(0), 3)
- Else
- c = c + 1: zh = Arr(t(i), 2) & "#"
- For y = 4 To 8
- .Cells(h(y - 4), c) = Arr(t(i), y)
- Next
- .[r32] = Arr(t(i), 3)
- .[r35] = Arr(t(i), 3)
- End If
- .[n6] = IIf(Right(zh, 1) = "、", Left(zh, Len(zh) - 1), zh)
- End With
- Next
- Application.ScreenUpdating = True
- MsgBox "OK"
- End Sub
复制代码 |
|