0

使用 vbscript,如何仅从可见单元格中查找/搜索 excel 中的单词。即如果一个词出现在任何隐藏的行或列中,它不应该返回那个。

目前,我使用如下,但无论可见性如何,它都会返回文本。如何为此限制可见性?

设置 foundText = excelFile.worksheets(i).Range("A1:H500").Find("Hello")

4

1 回答 1

0

您可以使用xlCellTypeVisible限定符仅过滤可见单元格。就是这样:

Const xlCellTypeVisible = 12

Dim r
Set r = excelFile.Worksheets(i).Range("A1:H500").SpecialCells(xlCellTypeVisible).Find("Hello")

If r Is Nothing Then
    MsgBox "Text not found in a visible cell."
Else
    MsgBox "Text found in a visible cell."
End If
于 2014-10-16T14:05:40.930 回答