Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果在指定列中上下行不同,您将如何插入一行。例如: 您希望在第 2 行下插入一行并将第 3 行向下移动。 A1 : Hello A2 : Hello A3 : Goodbye
A1 : Hello A2 : Hello A3 : Goodbye
谢谢!
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