Excel 如何将数据导入模板生成新的EXCEL文件

 我来答
历史这坛酒
2016-11-24 · 以人为镜明得失,以史为镜知兴替。
历史这坛酒
采纳数:51 获赞数:257

向TA提问 私信TA
展开全部
代码:
Sub Macro1()
Dim arr, brr(), crr(1 To 30, 3 To 8), d As Object, k, t, a, i&, j&, m&, l& Dim w As WorksheetFunction, sh As Worksheet, wb As Workbook Application.ScreenUpdating = False Application.DisplayAlerts = False
Set d = CreateObject("scripting.dictionary") arr = [a1].CurrentRegion For i = 2 To UBound(arr)
s = arr(i, 2) & "_" & arr(i, 3) d(s) = d(s) & "," & i Next
k = d.Keys t = d.Items
Set sh = Sheets("模板") Set w = WorksheetFunction For i = 0 To d.Count - 1 a = Split(t(i), ",")
ReDim brr(1 To w.RoundUp(UBound(a) / 30, 0) * 30, 3 To 8) For j = 1 To UBound(a) brr(j, 3) = j For l = 4 To 8
brr(j, l) = arr(a(j), l) Next Next m = j - 1
For j = w.RoundUp(m / 30, 0) * 30 To 1 Step -30 f = j - 29
If wb Is Nothing Then sh.Copy
Set wb = ActiveWorkbook Else
sh.Copy Before:=wb.Sheets(1) End If
With ActiveSheet
.[A2] = .[A2] & Split(k(i), "_")(0) .[A3] = .[A3] & Split(k(i), "_")(1)
If m <= 30 Then
.[a5].Resize(m, 6) = brr .Name = k(i) Else
Erase crr n = 0
For v = f To f + 29 n = n + 1 For l = 3 To 8
crr(n, l) = brr(v, l) Next Next
.[a5].Resize(30, 6) = crr End If End With Next
If m > 30 Then
For j = 1 To wb.Sheets.Count wb.Sheets(j).Name = k(i) & j Next End If
wb.Close True, Filename:=ThisWorkbook.Path & "\" & k(i) & ".xls" Set wb = Nothing Next
Application.DisplayAlerts = True Application.ScreenUpdating = True MsgBox "ok" End Sub
博思aippt
2024-07-20 广告
作为深圳市博思云创科技有限公司的工作人员,对于Word文档生成PPT的操作,我们有以下建议:1. 使用另存为功能:在Word中编辑完文档后,点击文件->另存为,选择PowerPoint演示文稿(*.pptx)格式,即可将文档内容转换为PPT... 点击进入详情页
本回答由博思aippt提供
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式