|
Private Sub Worksheet_Change(ByVal T As Range)
If T.Address = "$C$1" Then '关键字(词)单元格
If Len(T) = 0 Then Exit Sub
ReDim brr(1 To 10000, 1 To 7)
ReDim crr(1 To 100000, 1 To 7)
f = Dir(ThisWorkbook.Path & "\*.xls*")
Do While f <> ""
If f <> ThisWorkbook.Name Then
Set wb = GetObject(ThisWorkbook.Path & "\" & f)
arr = wb.Sheets(1).[A1].CurrentRegion
If InStr(T, " ") = 0 Then
For i = 2 To UBound(arr)
If InStr(arr(i, 3), T) > 0 Then
N = N + 1
For j = 1 To UBound(arr, 2)
brr(N, j) = arr(i, j)
Next
End If
Next
Else
s1 = Split(T, " ")(0): s2 = Split(T, " ")(1)
For i = 2 To UBound(arr)
If InStr(arr(i, 3), s1) > 0 And InStr(arr(i, 3), s2) > 0 Then
m = m + 1
For j = 1 To UBound(arr, 2)
crr(m, j) = arr(i, j)
Next
End If
Next
End If
wb.Close False
End If
f = Dir
Loop
If N > 0 Then
Range("A3:G" & [C65536].End(2).Row).ClearContents
[A3].Resize(N, 7) = brr
End If
If m > 0 Then
Range("A3:G" & [C65536].End(2).Row).ClearContents
[A3].Resize(m, 7) = crr
End If
End If
End Sub
|
评分
-
1
查看全部评分
-
|