我有一个脚本可以删除每个工作表上的1-4行,但如果它的名称是“Sheet1”,它希望它跳过工作表
Sub RowDelete()
Dim xWs As Worksheet
Set xWs = ActiveSheet
ThisWorkbook.Worksheets.Select
Rows("1:4").Select
Selection.Delete
xWs.Select
End Sub
答案 0 :(得分:3)
通过 FOR EACH循环:
运行它Sub RowDelete()
Dim xWs As Worksheet
For Each xWs In Worksheets
If xWs.Name <> "Sheet1" Then
xWs.Rows("1:4").Delete
End If
Next xWs
End Sub
顺便说一句,尝试不使用.Select来学习编码。