如何循环到特定的命名范围?
我想删除命名范围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
没有任何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