Last active
February 27, 2018 04:16
-
-
Save DuongAQ/7c449578ade94177048c6f8cb515ff6e 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 Import_from_ClosedWB() 'Copy dữ liệu từ nhiều sheet trong 1 workbook đang đóng | |
Const sPath="D:\Temp\" 'Đường dẫn tới thư mục chứa workbook đang đóng | |
Dim sFil As String | |
Dim owb As Workbook | |
Dim ws As Worksheet | |
Dim sh As Worksheet | |
Application.ScreenUpdating = False 'Tắt chức năng cập nhật màn hình | |
Set ws=Sheet1 | |
sFil=Dir(sPath & "*.xl*") 'Tên workbook cần lấy dữ liệu | |
Do While sFil <> "" 'Thực hiện khi workbook cần lấy dữ liệu có tồn tại | |
Set owb=Workbooks.Open(sPath & sFil) | |
For Each sh In ActiveWorkbook.Sheets 'Vòng lặp xét tới từng sheet | |
sh.[A2:AZ2000]=sh.[A2:AZ2000].Value 'Loại bỏ công thức, chỉ lấy giá trị | |
sh.Copy After:=ws 'Copy và paste sang workbook kết quả | |
owb.Close False 'Đóng workbook nhưng không thực hiện lưu | |
Next sh | |
sFil=Dir | |
Loop | |
Application.ScreenUpdating = True 'Mở chức năng cập nhật màn hình | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment