|
我有从1号到31号的数据表,以及一个总表的文件,需要导入到一个新的excel文件里,分别是导入到1-31的表格里,总表导入到“总”的表格里。
同时要考虑有些月份只有30天,有时并不从1号开始。
之前朋友帮助写了一个,但表格重新调整了,以下内容应该做哪些调整?谢谢。
Sub 导入所有日期数据()
Dim sh As Worksheet, myPath$, f$, wb As Workbook, t, shn$, d As Object
Set d = CreateObject("scripting.dictionary")
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each sh In Sheets
Set d(sh.Name) = sh
Next
Set wb = ThisWorkbook
myPath = ThisWorkbook.Path & "\"
f = Dir(myPath & "*.xls")
Do While f <> ""
t = Mid(f, InStrRev(f, "-") + 1, 2)
If IsNumeric(t) Then shn = Val(t)
Else
shn = "总"
End If
With GetObject(myPath & f)
If d.Exists(shn) Then
Set sh = d(shn)
sh.Cells.Clear
.ActiveSheet.Cells.Copy sh.[a1]
End If
.Close False
End With
f = Dir()
Loop
Application.ScreenUpdating = True
End Sub
例文档.rar
(69.57 KB, 下载次数: 13)
|
|