Dạ chào thầy, Em viết gộp nhiều sheet vào 1 sheet nhưng mà vòng lặp không chạy ạ. Chỉ chạy 1 sheet duy nhất, thầy giúp em với ạ
Sub Ivy()
Dim Shdau As Integer
Dim Shcuoi As Integer
Dim Dongcuoi As Long
Dim MaxRow As Long
Dim i As Integer
Dim KC As Long
Dim Dongdau As Long
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
.DisplayAlerts = False
End With
With Sheet3
Shdau = .Range("F1").Value
Shcuoi = .Range("G1").Value
Dongcuoi = .Range("B" & Rows.Count).End(xlUp).Row
End With
For i = Shdau To Shcuoi
Shdau = Sheet3.Range("F1").Value
Shcuoi = Sheet3.Range("G1").Value
Dongcuoi = Sheet3.Range("B" & Rows.Count).End(xlUp).Row
MaxRow = ThisWorkbook.Sheets(i).Range("B" & Rows.Count).End(xlUp).Row
Dongdau = 2
KC = MaxRow - Dongdau + 1
Sheet3.Range("A" & Dongcuoi + 1 & ":I" & Dongcuoi + KC).Value = Sheets(i).Range("A" & 2 & ":I" & MaxRow).Value
Next i
With Application
.DisplayAlerts = True
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With
End Sub
Chào bạn bạn có thể đẩy file lên được không?
https://drive.google.com/file/d/1sTv2... dạ Thầy xem giúp em với ạ.
Chào bạn bạn để các sheets theo thứ tự sau: sheet3, data,sheet2, sheet4, tại ô F1 để 1 và G1 để 4 rồi thử lại nhé. Lưu ý xóa hết các dữ liệu cũ