第1个回答 2022-12-03
excel表格隔行删除可以用下面的代码,如果清除偶数行,代码:
Sub Macro1()
r1 = ActiveSheet.Cells(Rows.Count, 4).End(xlUp).Row
Rows(2).Select
For i = 4 To r1 Step 2
Application.Union(Selection, Rows(i)).Select
Next
Selection.ClearContents
End Sub
如果清除奇数行,代码
Sub Macro1()
r1 = ActiveSheet.Cells(Rows.Count, 4).End(xlUp).Row
Rows(1).Select
For i = 3 To r1 Step 2
Application.Union(Selection, Rows(i)).Select
Next
Selection.ClearContents
End Sub