两个你自己看吧
第一个
Sub deletewords()
Dim words()
x = InputBox("输入删除单词的个数(最小为1)", "删除单词个数", 1)
If Application.Evaluate("=isnumber(" & x & ")") = False Then
MsgBox ("请不要输入文本,程序即将结束")
肆谨段 Exit Sub
ElseIf x = 0 Then
MsgBox ("输入的个数为0,程序即将结束")
Exit Sub
End If
ReDim words(1 To x)
For i_words = 1 To x
words(i_words) = InputBox("请输入需删除的单词", "删除的单词")
If words(i_words) = "" Then
MsgBox ("未输入单词,程序即将结束")
Exit Sub
End If
Next i_words
For i_1 = 1 To x
For i = 2 To 501
If InStr(Range("B" & CStr(i)).Text, words(i_1)) > 0 Then
Rows(CStr(i) & ":" & CStr(i)).Select
Selection.Delete shift:=xlUp
i = i - 1
End If
Next i
Next i_1
End Sub
第二个
Sub deletewords_2()
Dim words()
ReDim words(1 To Cells(65536, 15).End(xlUp).Row)
For i_words = 1 To Cells(65536, 15).End(xlUp).Row
words(i_words) = Cells(i_words, 15)
Next i_words
For i_1 = 1 To Cells(65536, 15).End(xlUp).Row
For i = 2 To 501
晌兄If InStr(Range("B" & CStr(i)).Text, words(i_1)) > 0 Then
Rows(CStr(i) & ":" & CStr(i)).Select
Selection.Delete shift:=xlUp
i = i - 1
End If
Next i
Next i_1
End Sub
第一个是需要你事先手动输入删除单词的个数及相应的单词
第二个是需要你事先将要删除的单词复制到O(从o1单元格开始)列然后运行程序即可,如果你想将需删除的单词复制到其它列则 Cells(65536, 15).End(xlUp).Row 中的15改为其它列的列号即可(注意一共有两处)A列——1 B列——2 C列——3 ... O列——15 以此类推
同时需要改的还是 Cells(i_words, 15) 这里边的15
上边的两个我只进行了简单测试,暂时裂誉没有发现问题,如有问题你在追问吧