|
Sub wwww()
Dim d As Object, sht As Worksheet, sht1 As Worksheet, sht2 As Worksheet, wb As Workbook, file As String, arr, arr1()
Set d = CreateObject("scripting.dictionary")
Set sht = Worksheets("筛选条件")
Set sht1 = Worksheets("筛选数据")
n = sht.UsedRange.Rows.Count
arr = sht.[a2].Resize(n, 3)
For J = 2 To UBound(arr)
If Len(arr(J, 1)) > 0 Then d(CDate(arr(J, 1))) = J
If Len(arr(J, 2)) > 0 Then d(arr(J, 2)) = J
If Len(arr(J, 3)) > 0 Then d(arr(J, 3)) = J
Next J
file = Dir(ThisWorkbook.Path & "\*.xlsx")
Do While file <> ""
If file <> ThisWorkbook.Name Then
Workbooks.Open ThisWorkbook.Path & "\" & file
Set wb = ActiveWorkbook
Set sht2 = wb.Worksheets(1)
arr = sht2.UsedRange
For J = 3 To UBound(arr)
If d.exists(arr(J, 2)) And d.exists(arr(J, 5)) And d.exists(arr(J, 4)) Then
m = m + 1
ReDim Preserve arr1(1 To m)
arr1(m) = Application.Index(arr, J, 0)
End If
Next J
wb.Close
End If
file = Dir
Loop
sht1.UsedRange.Offset(1).ClearContents
If m = 0 Then Exit Sub
sht1.[a2].Resize(m, UBound(arr, 2)) = Application.Transpose(Application.Transpose(arr1))
End Sub
|
评分
-
1
查看全部评分
-
|