excel - 如何从Excel VBA中的Find函数获取单元格地址

标签 excel vba find

如何使用“查找”功能获取单元格地址。

这是代码

Dim Found As Range

Set Found = Worksheets("Sheet 1").Cells.Find(What:="test", LookAt:=xlWhole, MatchCase:=True)

If Not Found Is Nothing Then
    ' do something
End If

当我调试代码时,“Found”变量包含一个“字符串”而不是单元格地址。

最佳答案

看来你可以只使用 found.address 即使它显示为字符串。下面的代码对我有用。

Sub findCellAddress()

    Dim ra As Range

    Set ra = Cells.Find(What:="fff", LookIn:=xlFormulas, LookAt _
        :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
        False, SearchFormat:=False)

    If ra Is Nothing Then
        MsgBox ("Not found")
        Else
        MsgBox (ra.Address)
    End If

End Sub

关于excel - 如何从Excel VBA中的Find函数获取单元格地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41008736/

相关文章:

linux - 递归地从多个文件中删除非 ASCII 字符

excel - 如何更改 Yii2 krajee 网格导出中的导出表/文档属性?

sql-server - 读取 excel 源代码并根据 ssis 中的标题运行 sp

vba - 在 VBA 中更改 Windows 7 及更早版本任务栏上的 Microsoft Excel 图标

vba - 查找ParamArray元素零的行

excel - 有人能解释一下这个 Excel 2010 或更早版本的密码保护器是如何工作的吗

regex - 使用正则表达式查找和替换字符串中模式的所有实例

arrays - 检查数组 VBA 的值

c++ - 使用c++查找窗口并修改控件

bash - 如何使用查找递归地转换 JPG 图像?