Created
March 5, 2018 03:44
-
-
Save DuongAQ/eef1120379691285f2b147b87c392681 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub OpenImp3() 'Lấy nội dung từ 1 vùng xác định | |
Const sPath="C:\Test\" 'Đường dẫn tới thư mục | |
Dim sFil As String | |
Dim owb As Workbook | |
Dim ws As Worksheet | |
Dim lr as long | |
Set ws=Sheet1 | |
sFil=Dir(sPath & "*.xl*") | |
Do While sFil <> "" | |
Set owb=Workbooks.Open(sPath & sFil) 'Mở workbook cần lấy nội dung | |
'Lọc nội dung cần lấy trong vùng từ A1 tới dòng cuối cột F, giá trị lọc là England ở cột A | |
Range("A1", Range("F" & Rows.Count).End(xlUp)).AutoFilter Field:=1, Criteria1:="England" | |
'Nếu có kết quả lọc thì copy dữ liệu | |
lr=Range("F" & Rows.Count).End(xlUp).Row | |
If lr > 1 Then Range("A2", Range("F" & Rows.Count).End(xlUp)).Copy ws.Range("A" & Rows.Count).End(xlUp)(2) | |
'Đóng workbook đã mở, không lưu file | |
owb.Close False | |
sFil=Dir | |
Loop | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment