Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel宏搜索文本,如果找到则弹出框_Excel_Vba - Fatal编程技术网

Excel宏搜索文本,如果找到则弹出框

Excel宏搜索文本,如果找到则弹出框,excel,vba,Excel,Vba,我对Excel不是很有经验,但我想知道是否可以制作一个宏来执行以下操作: 我希望它在整个工作表(工作表名称为“发票”)中搜索“警报”一词。如果单词出现在工作表上,我希望出现一个弹出框 如果可能,请告诉我。如果在发票上发现“警报”,将创建msbox: Sub TestFind() Dim found As Variant Set found = Sheets("Invoice").Cells.Find("alert", Sheets("Invoice").Cells(1, 1)

我对Excel不是很有经验,但我想知道是否可以制作一个宏来执行以下操作:

我希望它在整个工作表(工作表名称为“发票”)中搜索“警报”一词。如果单词出现在工作表上,我希望出现一个弹出框


如果可能,请告诉我。

如果在发票上发现“警报”,将创建msbox:

Sub TestFind()

    Dim found As Variant

    Set found = Sheets("Invoice").Cells.Find("alert", Sheets("Invoice").Cells(1, 1), xlValues, xlPart)

    If (Not found Is Nothing) Then

        'found
        MsgBox "Found " & found, vbOKOnly, "Found"
    Else

        'not found

    End If

End Sub

感谢您的快速回复,出于某种原因,它说下标超出范围。可能是我做错了……我还有两张工作表有关系吗?虽然发票是我唯一需要的东西,但我的直觉是正确的,不知怎么的,我把它搞砸了,但现在它工作得很好。万分感谢!!!!!