我想删除命名范围rbTop和rbBottom
之间的所有行Range("rbBottom").Value = ""
Range("rbTop").Select
Do While (Selection.Offset(1, 0).Value <> "")
Selection.Offset(1, 0).EntireRow.Delete
Loop
这样可行,但我想稍微缩短一下
Range("rbTop").Select
Do While (Selection.Offset(1, 0).Name <> "rbBottom") // how to write this line ?
Selection.Offset(1, 0).EntireRow.Delete
Loop
答案 0 :(得分:4)
没有任何Select
或循环:
Sub Cull()
Dim rng1 As Range
Set rng1 = Range(Range("rbtop"), Range("rbbottom"))
If rng1.Rows.Count > 2 Then rng1.Offset(1, 0).Resize(rng1.Rows.Count - 2, 1).EntireRow.Delete
End Sub