|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
neke520 发表于 2014-5-12 23:07 - Sub Macro1()
- Dim MyPath$, MyName$, sh As Worksheet, arr$(), i&, r&, wb As Workbook
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False '新加
- ReDim arr(2 To Worksheets.Count)
- For i = 2 To Worksheets.Count
- With Worksheets(i)
- .UsedRange.Offset(3).Clear
- arr(i) = .Name
- End With
- Next
- Set wb = ThisWorkbook
- r = Rows.Count
- MyPath = ThisWorkbook.Path & ""
- MyName = Dir(MyPath & "*.xlsx")
- ' Application.AskToUpdateLinks = False'如果测试还出现请启用这一句
- Do While MyName <> ""
- With GetObject(MyPath & MyName)
- For Each sh In .Sheets
- For i = 2 To UBound(arr)
- If InStr(sh.Name, arr(i)) Then
- sh.UsedRange.Offset(3).Copy wb.Worksheets(arr(i)).Cells(r, 1).End(xlUp).Offset(1)
- Exit For
- End If
- Next
- Next
- .Close False
- End With
- MyName = Dir
- Loop
- Application.ScreenUpdating = True
-
- End Sub
复制代码 |
|