答案 0 :(得分:0)
试试这个。应该适合你的榜样......
Sub Dates()
Dim LastRow As Long
Dim RowIns As Integer
LastRow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To LastRow
Cont:
If Cells(i, 1).Value = "" Then
GoTo Cont2
End If
RowIns = Cells(i, 4).Value - Cells(i, 3).Value
If RowIns <= 0 Then
i = i + 1
GoTo Cont
End If
Rows(i + 1 & ":" & RowIns + i).Insert Shift:=xlDown
Range("C" & i).Select
Selection.AutoFill Destination:=Range("C" & i & ":C" & RowIns + i), Type:=xlFillDefault
Range("A" & i & ":B" & i).Select
Selection.AutoFill Destination:=Range("A" & i & ":B" & RowIns + i), Type:=xlFillCopy
LastRow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
i = i + RowIns + 1
GoTo Cont
Next
Cont2:
Columns(4).EntireColumn.Delete
End Sub