查找"Cells.Find"的单元格引用.功能 [英] Finding the cell reference of a "Cells.Find" function
问题描述
我正在使用下面的代码查找用户搜索的值("strFindWhat"),该值已输入到单元格中,然后按下按钮以触发此子项.该系统包含一长串数据,用户将搜索例如产品编号,以便他们可以快速查看相应的批号.
I am using the code below to find a value the user has searched for ("strFindWhat") which is entered into a cell and a button is then pressed to trigger this sub. The system conatains a long list of data and the user will be searching for say a product number so that they can quickly see the corresponding batch no.
Cells.Find(What:=strFindWhat, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False).Select
我想做的是找到对该代码所找到的单元格的引用.这样我就可以更改找到的单元格的颜色或行,以突出显示所需的数据,以便他们可以更清晰地看到它们.我通过使整个函数等于一个变量来尝试了显而易见的方法:
What I want to do is find the refrence to the cell that is found by this code. So that I can change the colour or maybe row of the found cell in order to highlight the data they need so they can see it clearer. I have tried the obvious by making the whole function equal a variable:
foundCell = Cells.Find(What:=strFindWhat, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False).Select
"foundCell"的值总是空白,我希望有人知道找到对找到的单元格的引用的方法吗?
The value of "foundCell" always comes out as blank and I was hoping someone knows of a way to find the reference to the found cell?
推荐答案
要找到地址,您可以这样做
In order to find the address you could do sth like that
Dim foundCell As Range
Set foundCell = Cells.Find(What:=strFindWhat, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False)
If Not (foundCell Is Nothing) Then
Debug.Print foundCell.Address
End If
这篇关于查找"Cells.Find"的单元格引用.功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!