我的范围是5k左右的单元格,我想删除其上有特定文本的单元格。 I.E.而且,a,是,或者,等等,有没有办法解决这个问题?请帮忙。
[A2].Select
Range("A2", Selection.End(xlDown)).Select
Dim crnge As Range
Dim wdelim
Dim rdelim
wdelim = Split("on,the,this,in,at,of,for,what,w,all,on,with", ",")
Set crnge = Selection
For Each rdelim In wdelim
crnge.wdelim.Select
.Delete (xlUp)
Next
我知道这段代码不起作用,这正是我想要做的,但我不知道该怎么做。
答案 0 :(得分:1)
这里我过滤了数组中每个元素的数据,并删除了整行的可见单元格。
Sub DeleteFilteredRows()
Dim v
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
For Each v In Split("on,the,this,in,at,of,for,what,w,all,on,with", ",")
With Range("A1").CurrentRegion
On Error Resume Next
'If you want all rows that have any of this phrases anywhere in
'the cell use: Criteria1:="=*" & v & "*"
.AutoFilter Field:=1, Criteria1:="=" & v , Operator:=xlAnd
.Offset(1).SpecialCells(xlCellTypeVisible).EntireRow.Delete
On Error GoTo 0
.AutoFilter
End With
Next
With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With
End Sub