Chào bạn bạn có thể đẩy code lên không ạ?
Đây là code của e:
Sub Data_Compound()
'Open and select file
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = True
.Show
'Set variable for selected items
Dim i As Long
For i = 1 To .SelectedItems.Count
'Set variable for workbook
Dim wb_1 As Workbook
Dim wb_select As Workbook
Set wb_1 = ThisWorkbook
Set wb_select = Workbooks.Open(.SelectedItems(i))
'Find last row and range distance
Dim DongCuoi_wb2 As Long
DongCuoi_wb2 = wb_select.Sheet1("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_wb1 As Long
DongCuoi_wb1 = wb_1.Sheet2.Range("A" & Rows.Count).End(xlUp).Row
' Enter data to wb1
wb_1.Sheet2.Range("A" & DongCuoi_wb1 + 1 & ":C" & DongCuoi_wb1 + KhoangCach_wb2).Value = _
wb_select.Sheet1.Range("A" & DongDau_wb2 & ":C" & DongCuoi_wb2).Value
'Close workbook selected
wb_select.Close savechanges:=False
Next i
End With
End Sub
Chào bạn bạn muốn hiện file để chọn từng file bạn xem cách này nhé:
With Application.FileDialog(msoFileDialogFilePicker) // phần này là chọn từng file của bạn là chọn forder
.AllowMultiSelect = True
.Show
.Filters.Add "Excel file - Gitiho", "*.xlsm" // thực hiện lọc file
hoặc bạn có thể đọc của tài liệu microsoft:https://docs.microsoft.com/en-us/offi...
Đây là hình ảnh khi chạy code gộp dữ liệu https://imgur.com/mVEN7iW
Còn đây là hình ảnh khi mở file explorer https://imgur.com/SF8lZjs
Sau khi thêm dòng code của thầy thì vẫn không hiện file cần gộp.
Chào bạn msoFileDialogFilePicker là chọn từng file , còn msoFileDialogFolderPicker là chọn cả forder nó tự lấy file excel trong đó.
Vậy mà kiểm tra hoài vẫn không biết sai chỗ nào. Cảm ơn thầy.
chúc bạn học tốt cùng gitiho