|
w学无止境 发表于 2013-9-18 16:56
你好,请看一下,有些修改。谢谢
假设工作簿打开密码是"abc":- Sub Macro1()
- Dim MyPath$, MyName$, sh As Worksheet, sht As Worksheet
- Application.ScreenUpdating = False
- Set sh = ActiveSheet
- MyPath = ThisWorkbook.Path & ""
- MyName = Dir(MyPath & "*.xls")
- [a1].CurrentRegion.Offset(2).Clear
- Do While MyName <> ""
- If MyName <> ThisWorkbook.Name Then
- With Workbooks.Open(MyPath & MyName, Password:="abc")
- For Each sht In .Sheets
- If InStr(sht.Name, "2013") > 0 And sht.[a1].CurrentRegion.Rows.Count > 2 Then
- lr = sh.[a1].CurrentRegion.Rows.Count + 1
- r = sht.[a1].CurrentRegion.Rows.Count - 2
- sh.Cells(lr, 1).Resize(r) = MyName
- sh.Cells(lr, 2).Resize(r) = sht.Name
- sht.[a1].CurrentRegion.Offset(2).Copy sh.Cells(lr, 3)
- End If
- Next
- .Close False
- End With
- End If
- MyName = Dir
- Loop
- Application.ScreenUpdating = True
- MsgBox "ok"
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|