|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 新建工作表()
Application.ScreenUpdating = False
Dim d As Object
Set d = CreateObject("scripting.dictionary")
For Each sh In Sheets
d(sh.Name) = ""
Next sh
w = InputBox("请输入名称", , Format(Date, "m月"))
If w = "" Then End
If d.exists(w) Then MsgBox w & "工作表已经存在,不能重复新建!": End
Sheets("模板").Copy after:=Sheets(Sheets.Count)
Sheets(Sheets.Count).Name = w
Application.ScreenUpdating = True
End Sub
Sub hz()
Application.ScreenUpdating = False
Set sh = ThisWorkbook.ActiveSheet
mc = sh.Name
f = Dir(ThisWorkbook.Path & "\*.xls*")
Do While f <> ""
If f <> ThisWorkbook.Name Then
If InStr(f, mc) > 0 Then
Set wb = Workbooks.Open(ThisWorkbook.Path & "\" & f, 0)
ar = wb.Worksheets(1).Range("b5:b30")
wb.Close False
y = sh.Cells(3, Columns.Count).End(xlToLeft).Column + 1
sh.Cells(5, y).Resize(UBound(ar), 1) = ar
sh.Cells(3, y) = Split(f, ".")(0)
End If
End If
f = Dir
Loop
sh.Cells(3, y + 1) = "合计"
sh.Range(sh.Cells(3, 2), sh.Cells(30, y + 1)).Borders.LineStyle = 1
For i = 5 To 30
sh.Cells(i, y + 1) = Application.Sum(sh.Range(sh.Cells(i, 2), sh.Cells(i, y)))
Next i
Application.ScreenUpdating = True
MsgBox "数据导入完毕!"
End Sub
|
|