如何使用“查找”功能获取单元格地址。
这是代码
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/