我想创建一个用于检查行的脚本,第二列上的所有行都已完成,检查下一行,依此类推。
我想从excel表中删除一些单词,问题是有很多单词。
我想做这样的事情:
对于每个包含文本的单元格,IF A1 = car OR boat OR train ...
。
如果单元格包含指定的文本,则将其删除。
有人可以提供一些例子吗?
感谢, 塞巴斯蒂安
答案 0 :(得分:1)
尝试通过VBA使用查找/替换。它非常快。
Sub SearchAndDestroy()
Dim SearchWordCell As Range
For Each SearchWordCell In Range("A1:A50") 'Asuming that range A1:A50 is the list with the 50 words you want to search/replace
Range("C10:R4510").Replace What:=SearchWordCell.Value, Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False 'Asuming that range C10:R4510 is the table where you want to find and delete the words.
Next SearchWordCell
End Sub
只需根据需要进行修改。
答案 1 :(得分:0)
在一个范围内存储您要删除的单词列表,并循环显示此范围。
示例:
Sub DeleteFromWordList()
Dim InRange As Range, CritRange As Range
Dim InCell As Range, CritCell As Range
Set InRange = Selection ' all selected source cells
Set CritRange = Range("Words2Delete") ' the named range of words to be excluded
For Each InCell In InRange.Cells
For Each CritCell In CritRange.Cells
If InCell = CritCell Then
InCell = "" ' blank it
Exit For ' exit inner for
End If
Next CritCell
Next InCell
End Sub
希望有所帮助......祝你好运MikeD