Skip to content

Instantly share code, notes, and snippets.

Created February 20, 2018 17:32
Show Gist options
  • Select an option

  • Save anonymous/0486f94a6c21ec1381a38053910cb0d8 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/0486f94a6c21ec1381a38053910cb0d8 to your computer and use it in GitHub Desktop.
Sub ImportData_Test() 'Lấy dữ liệu từ 1 Workbook khác
Dim owb As Workbook
Dim sh As Worksheet
Set sh=Sheet1
'Mở file cần lấy dữ liệu
Set owb=Workbooks.Open("C:\Test\England.xlsm")
'C:\Test\ là thư mục chứa file
'England.xlsm là tên file, dạng file
'Copy vùng dữ liệu cần lấy: Vùng A1:F100 trong Sheet Data của file cần lấy dữ liệu
owb.Sheets("Data").Range("A1:F100").Copy
'Dán vào vị trí cần lấy kết quả: ô A1 trong Sheet1 của Workbook kết quả
sh.Range("A1").PasteSpecial xlPasteValues
'Đóng file cần lấy dữ liệu
owb.Close False
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment