|
李全有 发表于 2015-4-4 07:02
真诚求助。 - Sub 合格数据()
- Dim FileName$, Fn$, Mypath$, Wb As Workbook, Sht As Worksheet, Zsht As Worksheet
- Dim Arr, i%
- With Application.FileDialog(msoFileDialogFolderPicker)
- If .Show Then Mypath = .SelectedItems(1) Else Exit Sub
- End With
- If Right(Mypath, 1) <> "" Then Mypath = Mypath & ""
- FileName = Dir(Mypath & "*.xlsx")
- Set Zsht = ThisWorkbook.Sheets("sheet2")
- Zsht.Cells.ClearContents
- Application.ScreenUpdating = False
- t = Timer
- Do While FileName <> ""
- If FileName <> ThisWorkbook.Name Then
- Fn = Mypath & FileName
- Set Wb = Workbooks.Open(Fn)
- Set Sht = Wb.Sheets(1)
- Arr = Sht.UsedRange
- n = UBound(Arr, 2)
- For i = 1 To UBound(Arr)
- If Cells(i, n - 2) = Cells(i, n - 4) And Cells(i, n - 2) = Cells(i, n) Then
- Sht.Range(Cells(i, 1), Cells(i, n)).Copy Zsht.[a1].Offset(Zsht.Cells(Rows.Count, 1).End(3).Row)
- Zsht.Cells(Zsht.Cells(Rows.Count, 1).End(3).Row, n + 2) = Wb.Name
- End If
- Next
- Wb.Close False
- End If
- FileName = Dir
- Loop
- Application.ScreenUpdating = True
- MsgBox "提取完成,用时" & Format(Timer - t, "0.00") & "秒"
- End Sub
复制代码 |
评分
-
查看全部评分
|