3个回答
展开全部
Sub 于生成文件()
Dim Rng As Range, Sh As Worksheet, Sh1 As Worksheet, Wb As Workbook
Dim Dic As Object, i&, j&, Filn$
Set Dic = CreateObject("Scripting.Dictionary")
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False
Filn = Dir(ThisWorkbook.Path & "\" & Format(Date, "于yyyymmdd生成*"), vbDirectory)
Do While Len(Filn) <> 0
Dic(Filn) = ""
Filn = Dir
Loop
If Not Dic.Exists(Format(Date, "于yyyymmdd生成")) Then MkDir ThisWorkbook.Path & "\" & Format(Date, "于yyyymmdd生成")
Set Dic = Nothing
For Each Sh In ThisWorkbook.Worksheets
Set Wb = Workbooks.Add
For i = 2 To Sh.Cells(Rows.Count, 1).End(xlUp).Row
Set Sh1 = Wb.Worksheets.Add
Sh1.Name = Sh.Cells(i, 1)
[A5] = Sh.Cells(i, 1)
[B3] = Sh.Cells(i, 2)
[C7] = Sh.Cells(i, 3)
[D11] = Sh.Cells(i, 4)
[E9] = Sh.Cells(i, 5)
Next i
Wb.SaveAs ThisWorkbook.Path & Format(Date, "\\于yyyymmdd生成\\") & Sh.Name
Wb.Close
Next Sh
Application.EnableEvents = True
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你没有说生成的文件夹里面的需求,如果只是建立文件夹,下面的一个语句就可以:
Sub x()
MkDir ThisWorkbook.Path & "\" & Format(Date, "于yyyymmdd生成")
End Sub
追问
看截图啊,文件夹里面的需求都说了啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |