|
BeMin 发表于 2014-8-5 22:08
语句已经按我的自己需求修改了,但有几个问题要赵老师指导一下:
1、我的表格有保护工作表,脚本此时不能 ... - Sub Macro1()
- Dim MyPath$, MyName$, sh As Worksheet, sht As Worksheet
- Application.ScreenUpdating = False
- Application.Calculation = xlManual
- Set sh = ActiveSheet
- MyPath = ThisWorkbook.Path & ""
- MyName = Dir(MyPath & "*.xls")
- [a1].CurrentRegion.Offset(7).Clear
- Do While MyName <> ""
- If MyName <> ThisWorkbook.Name Then
- With GetObject(MyPath & MyName)
- For Each sht In .Sheets
- If sht.Name <> "汇总" Then
- sht.Unprotect
- If sht.[a1].CurrentRegion.Rows.Count > 2 Then
- lr = sh.[a1].CurrentRegion.Rows.Count + 1
- r = sht.[a1].CurrentRegion.Rows.Count - 7
- sh.Cells(lr, 1).Resize(r) = MyName
- sh.Cells(lr, 2).Resize(r) = sht.Name
- sht.[a1].CurrentRegion.Offset(7).Copy sh.Cells(lr, 3)
- End If
- End If
- Next
- .Close False
- End With
- End If
- MyName = Dir
- Loop
- Application.Calculation = xlAutomatic
- Application.ScreenUpdating = True
- MsgBox "ok"
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|