Cho mình hỏi khai báo dòng đầu = 6 thì lại mất một dòng khi lấy dữ liệu, khi khai báo dòng đầu = 5 thì lại lấy được dòng bị mất?
link ảnh:
https://lenhuy9119.imgur.com/all/?thi...Code:
Sub File_TongQuat()
'Lay du lieu tu thu muc
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = True 'Cho phep chon nhieu doi tuong WB
.Show 'Hien thi
'Xac dinh file se duoc chon
Dim i As Long
'Su dung vong lap, chon xong file(WB) nay toi file tiep
For i = 1 To .SelectedItems.Count
'Gan bien cho cac WB
Dim WB_KQ As Workbook
Dim WB_Select As Workbook
Set WB_KQ = ThisWorkbook
Set WB_Select = Workbooks.Open(.SelectedItems(i))
'Tim vung du lieu can gan vao book 4
'vung = dongcuoi_wb2 - 1
Dim dongcuoi_wb2 As Long
dongcuoi_wb2 = WB_Select.Sheets("Cong_trinh").Range("E" & Rows.Count).End(xlUp).Row
Dim dongdau_wb2 As Long
dongdau_wb2 = 6
Dim vung As Long
vung = dongcuoi_wb2 - dongdau_wb2 + 1
'khai bao dong cuoi o book4
Dim dongcuoi_wb4 As Long
dongcuoi_wb4 = WB_KQ.Sheets("Sheet1").Range("E" & Rows.Count).End(xlUp).Row
'gan du lieu vao book 4
WB_KQ.Sheets("Sheet1").Range("A" & dongcuoi_wb4 + 1 & ":O" & vung + dongcuoi_wb4).Value = _
WB_Select.Sheets("Cong_trinh").Range("A" & dongdau_wb2 & ":O" & dongcuoi_wb2).Value
'Dong WB dang mo de lay du lieu lai(sau khi da lay xong)
WB_Select.Close SaveChanges:=False
Next i
End With
End sub