|
本帖最后由 a3348587 于 2014-5-5 16:05 编辑
我想让同一文件夹下的所有excel 把符合条件的信息复制到sheet2里。我新建一个excel然后执行以下命令。执行之后老是没反应,单个工作簿执行复制宏的时候是没问题。请大神帮忙解决下
Sub aa()
Dim ipath As String
Dim myfile As String
Application.ScreenUpdating = False
ipath = "C:\Documents and Settings\Administrator\桌面\VBA测试" & "\"
myfile = Dir(ipath & "*.xlsx")
If myfile <> "" Then
Do
Workbooks.Open ipath & myfile
Workbooks(myfile).Activate
Call fuzhi
Workbooks(myfile).Close True
myfile = Dir()
Loop While myfile <> ""
End If
End Sub
---------------------------------以下是复制宏----------------------------------------
Sub fuzhi()
Dim han
Dim lie
Dim data '
Dim arr()
Dim C
Application.ScreenUpdating = False
data = Sheets(1).[m65536].End(3).Row
ReDim arr(1 To data, 1 To 17)
C = 1
For han = 4 To data
If Cells(han, 17) > 0 Then
For lie = 1 To 17
arr(C, lie) = Cells(han, lie)
Next
C = C + 1
End If
Next han
Sheets(2).Range("a1").Resize(UBound(arr), 17) = arr
ActiveWorkbook.Save
End Sub
VBA测试.rar
(144.67 KB, 下载次数: 31)
|
|