Lam the nao de VBA khong bao loi
Compile error: Invalid or unqualified reference tai dong .SelectedItems.Count
Sub Gopdulieutongquat() 'mo thu muc, chon file gop du lieu vao
'Tao thu muc mo file
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = True
.Show
End With
'Xac dinh file nao duoc chon
Dim i As Long
For i = 1 To .SelectedItems.Count
'Gan bien cho cac workbook
Dim wb_KQ As Workbook
Dim wb_Select As Workbook
Set wb_KQ = ThisWorkbook
Set wb_Select = Workbooks.Open(.SelectedItems(i))
'Xac dinh dong cuoi cua book 2
Dim Dongcuoi_Wb2 As Long
Dongcuoi_Wb2 = Workbooks("Book2.xlsm").Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row
Dim Dongdau_Wb2 As Long
Dongdau_Wb2 = 2
Dim Khoangcach_Wb2 As Long
Khoangcach_Wb2 = Dongcuoi_Wb2 - Dongdau_Wb2 + 1
Dim Dongcuoi_Wb4 As Long
Dongcuoi_Wb4 = Workbooks("Book4.xlsm").Sheets("Data").Range("A" & Rows.Count).End(xlUp).Row
'Dua du lieu vao
Workbooks("Book4.xlsm").Sheets("Data").Range("A" & Dongcuoi_Wb4 + 1 & ":C" & Dongcuoi_Wb4 + Khoangcach_Wb2).Value = _
Workbooks("Book2.xlsm").Sheets("Sheet1").Range("A" & Dongdau_Wb2 & ":C" & Dongcuoi_Wb2).Value
'Dong wb lai
wb_Select.Close SaveChanges:=False
Next i
End With
End Sub