检查单元格中是否有多个数据之一

发布于 2024-11-09 14:18:03 字数 202 浏览 0 评论 0原文

我想制作一个检查行的脚本,第二个第一列上的所有行都完成后,检查下一行,依此类推。

我想从Excel表格中删除一些单词,问题是单词太多。

我想做这样的事情: 对于每个包含文本的单元格,IF A1 = 汽车或船或火车...。 如果单元格包含指定的文本,则将其删除。

谁能举一些例子吗?

谢谢, 塞巴斯蒂安

I want to make a Script that checks the rows, wen the second all the rows on the first column are done, check the next one, and so on.

I want to remove some words from an excel table, the problem is that there are a lot of words.

I'd like to do something like this:
IF A1 = car OR boat OR train ... for each cell that has text in it.
if the cell contains the specified text, to remove it.

Can anyone give some examples?

thanks,
Sebastian

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

安人多梦 2024-11-16 14:18:03

尝试通过 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

只需根据需要修改即可。

Try using Find/Replace through VBA. It is very fast.

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

Just modify as needed.

相守太难 2024-11-16 14:18:03

将要删除的单词列表存储在某个范围内,并循环浏览该范围。

示例:

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

Store the list of words that you want to delete in a range and cycle through this range.

Example:

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

Hope that helps .... good luck MikeD

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文