|
改一下。。。
- Private Sub Worksheet_Change(ByVal T As Range)
- Application.EnableEvents = False
- Application.ScreenUpdating = False
- If T.Address <> "$E$2" Then
- Exit Sub
- Else
- Set fso = CreateObject("Scripting.FileSystemObject")
- p = ThisWorkbook.Path & ""
- xm = T.Value
- ReDim brr(1 To 10000, 1 To 6)
- For Each f In fso.GetFolder(p).Files
- If LCase(f.Name) Like "*.xls*" Then
- If InStr(f, "~$") = 0 Then
- If InStr(f, ThisWorkbook.Name) = 0 Then
- Set wb = Workbooks.Open(f, 0)
- arr = wb.Sheets(1).UsedRange
- wb.Close 0
- For i = 3 To UBound(arr)
- If arr(i, 5) = T.Value Then
- m = m + 1
- brr(m, 1) = m
- For j = 2 To UBound(arr, 2)
- brr(m, j) = arr(i, j)
- Next
- End If
- Next
- End If
- End If
- End If
- Next
- Me.UsedRange.Offset(3).ClearContents
- If m > 0 Then Me.[a4].Resize(m, 6) = brr
- End If
- Application.EnableEvents = True
- Application.ScreenUpdating = True
- End Sub
复制代码
|
|