如附件, 1.在C列中查找关键字“Mixing tower U"所在行,删除此行(不包括此行)上面直到第二行的所有行(C1所在行保留)。 2.在C列中查找关键字“filler supply 05"所在行,删除此行(包括此行)向下所有行
本帖最后由 hwc2ycy 于 2012-10-29 12:38 编辑
- Sub FindDelete()
- '没有做大小写匹配
- Dim s1 As String, s2 As String
- Dim rg As Range
- Dim iRow As Long
- On Error Resume Next
- '关闭刷屏
- Application.ScreenUpdating = False
- s1 = "Mixing tower U"
- s2 = "filler supply 05"
- Set rg = Range("c:c").Find(s1)
- If (Not rg Is Nothing) Then
- If rg.Row <> 2 Then Range("c2:c" & rg.Row - 1).EntireRow.Delete
- End If
- Set rg = Nothing
- iRow = Range("a1").End(xlDown).Row
- Set rg = Range("c:c").Find(s2)
- If (Not rg Is Nothing) Then
- If rg.Row <> iRow Then Range("c" & rg.Row + 1 & ":c" & iRow).EntireRow.Delete
- End If
- End Sub
复制代码重新改了下,之前逻辑关系不够严谨。
|