[英]How to delete rows in VBA using targeted range
I have a sheet and I need to delete rows starting from A3:M3.我有一张工作表,我需要删除从 A3:M3 开始的行。 All rows below him should also be deleted.
他下面的所有行也应该被删除。 I'm using the code below and the entire rows now are empty.
我正在使用下面的代码,现在整行都是空的。
Any tips and tricks how to do it?任何提示和技巧如何做到这一点?
For i = 3 To 10
rws = "A" & i & ":" & "M" & i
Range(rws).EntireRow.Delete
Next
Please, try the next code:请尝试下一个代码:
Sub deleteRowsOver3()
Dim sh As Worksheet, lastR As Long
Set sh = ActiveSheet
lastR = sh.Range("A" & sh.rows.Count).End(xlUp).row
sh.Range("A3:A" & lastR).EntireRow.Delete
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.