Mình có bảng tính như file đính kèm mình muốn chèn vào 8 dòng ở mỗi cuối phân tích công việc. trong file Mình đã chèn như ở hạng mục công việc 1.làm sao để chèn thêm 8 dòng giống như vậy vào cuối các hạng công việc khác. mính cũng có viết đoạn code nhưng chạy bị báo lỗi như sau. Mong các bạn chỉ giúp.
Sub chen_dong()
Sheet5.Select
Dim a
Dim b
a = 8
Do
a = a + 1
If Sheet5.Cells(a, 3) = "" Then
b = a
Sheet5.Rows("a:a").Select
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
End If
If Cells(a, 4) = "" And Cells(a + 1, 4) = "" Then Exit Do
Loop
End Sub
Sub chen_dong()
Sheet5.Select
Dim a
Dim b
a = 8
Do
a = a + 1
If Sheet5.Cells(a, 3) = "" Then
b = a
Sheet5.Rows("a:a").Select
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
End If
If Cells(a, 4) = "" And Cells(a + 1, 4) = "" Then Exit Do
Loop
End Sub