这是我目前使用的语句。我需要找到一种方法来填充我插入的两行,使用我的新空行之前最后一个填充单元格的值。我该怎么做呢?
Sub Insert_Rows()
Dim r As Long, mcol As String, i As Long, s As Long, ncol As Long
' find last used cell in Column A
r = Cells(Rows.Count, "A").End(xlUp).Row
' get value of last used cell in column A
mcol = Cells(r, 1).Value
'find last used cell in Column B
s = Cells(Rows.Count, "B").End(xlUp).Row
' get value of last used cell in Column B
ncol = Cells(s, 1).Value
' insert rows by looping from bottom
For i = r To 2 Step -1
If Cells(i, 1).Value <> mcol Then
mcol = Cells(i, 1).Value
Rows(i + 1).Insert
Rows(i + 1).Insert
End If
Next i
End Sub