Skip to content

Instantly share code, notes, and snippets.

@DuongAQ
Created March 5, 2018 03:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DuongAQ/6b4473f01bb12f7b7844d93777b92e47 to your computer and use it in GitHub Desktop.
Save DuongAQ/6b4473f01bb12f7b7844d93777b92e47 to your computer and use it in GitHub Desktop.
Sub OpenImp() 'Mở file và sao chép dữ liệu sang file khác
Const sPath="C:\Test\" 'Thư mục chứa file
Dim sFil As String
Dim owb As Workbook
Dim ws As Worksheet
Set ws=Sheet1 'Xác định tên Sheet chứa kết quả (đích)
sFil=Dir(sPath & "*.xl*") 'Xác định loại file cần lấy
Do While sFil <> ""
Set owb=Workbooks.Open(sPath & sFil) 'Mở file cần copy
'Copy vùng dữ liệu từ A2 đến dòng cuối cột F
Range("A2", Range("F" & Rows.Count).End(xlUp)).Copy ws.Range("A" & Rows.Count).End(xlUp)(2)
'Đóng workbook mà không lưu
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