[英]Insert row when cell above and below are different
如果在指定的列的上方和下方的行不同,則如何插入行。 例如:
A1 : Hello
A2 : Hello
A3 : Goodbye
您可能想在第2行下插入一行,然后向下移動3。
謝謝!
Sub insert()
dim lastrow as long, i as long
With ActiveSheet
lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
For i = lastrow To 2 Step -1
If Not Cells(i, 1) = Cells(i - 1, 1) Then
Rows(i).insert shift:=xlShiftDown
End If
Next i
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.