Sub 复制当前工作簿的报表到临时工作簿()
'作者:yuanzhuping版主
Dim x As Integer
Dim sht As Worksheet
On Error Resume Next
For x = 1 To Workbooks.Count
If Workbooks(x).Name = "临时.xls" Then
For Each sht In Workbooks(x).Sheets
If sht.Name = "001" Then
MsgBox "已经有了001表", 64, "提示"
Exit Sub
End If
Next
Sheets("报表").Copy Before:=Workbooks("临时.xls").Sheets(1)
ActiveSheet.Name = "001"
Exit Sub
End If
Next
Workbooks.Add
ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & "\" & "临时"
ThisWorkbook.Activate
Sheets("报表").Copy Before:=Workbooks("临时.xls").Sheets(1)
ActiveSheet.Name = "001"
End Sub
需求说明:
'复制当前工作簿的“报表”工作表到“临时”工作簿为“001”表。
'如果“临时”工作簿未打开,就创建新工作簿为“临时”并在其中加入“001”表;
'如果“临时”工作簿已经打开,就直接加入“001”表。
'如果打开的“临时”工作簿中已经有“001”表,就报错退出。
'帖子地址:http://club.excelhome.net/dispbbs.asp?
boardid=2&replyid=875804&id=245219&page=1&skin=0&Star=2
' 删除指定文件 返回
Sub 删除指定文件()
Kill "E:\信件\1.xls"
End Sub
|
|
susan