|
- Sub Macro1()
- Dim MyPath$, MyName$, sh As Worksheet, shtyc As Worksheet, shtdc As Worksheet
- Application.ScreenUpdating = False
- Set shtyc = Workbooks("全年.xlsm").Sheets("遥测")
- Set shtdc = Workbooks("全年.xlsm").Sheets("对照")
- MyPath = ThisWorkbook.Path & ""
- MyName = Dir(MyPath & "*.xls")
- Do While MyName <> ""
- If MyName <> "全年.xlsm" Then
- Workbooks.Open (MyPath & MyName)
- With GetObject(MyPath & MyName)
- Sheets(1).Name = "自计"
- Sheets.Add after:=Sheets("自计")
- ActiveSheet.Name = "遥测"
- shtyc.Cells.Copy Workbooks(MyName).Sheets("遥测").Range("a1")
- Sheets.Add after:=Sheets("遥测")
- ActiveSheet.Name = "对照"
- shtdc.Cells.Copy Workbooks(MyName).Sheets("对照").Range("a1")
- .Close True
- End With
- End If
- MyName = Dir
- Loop
- Application.ScreenUpdating = True
- End Sub
复制代码 请楼主测试下可不可以…… |
|