|
改自示例代码:
Sub 宏1()
With Worksheets(2).UsedRange
Set c = .Find("合计", LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
If InStr(s, "," & c.Row & ":") < 1 Then s = s & "," & c.Row & ":" & c.Row
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
firstAddress = ""
Set c = .Find("小计", LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
If InStr(s, "," & c.Row & ":") < 1 Then s = s & "," & c.Row & ":" & c.Row
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
If Len(s) Then Range(Mid(s, 2)).Delete
End Sub |
|