Find function to locate result of a formula in a cell

0 votes

In order to return the cell reference, I'm attempting to search across column F for the number 9999.

Only when the number 9999 is entered into column F does my code provide the cell where this number is situated.

Formula-driven column F yields the result 9999 as the result of the formula's reasoning.

Dim foundRng as Range
Set foundRng = Range ("F1:F2000").Find("9999")
If foundRng is Nothing then
    MsgBox "Value not found"
Else
    MsgBox foundrng.Address
End if
End Sub
Nov 17 in Others by Kithuzzz
• 20,660 points
18 views

1 answer to this question.

0 votes

There are several attributes to the Find function. The majority of these are automatically set by Excel based on the most recent use. Excel will remember your most recent option even if you last used Find manually. Therefore, while using VBA, all pertinent properties should be set.

Sub FindCell()

    Dim foundRng As Range
    
    Set foundRng = Range("F1:F2000").Find(What:="9999", _
                                          After:=Cells(2000, "F"), _
                                          LookIn:=vbValues, _
                                          LookAt:=xlWhole, _
                                          SearchOrder:=xlByRows, _
                                          SearchDirection:=xlNext, _
                                          MatchCase:=False)
    If foundRng Is Nothing Then
        MsgBox "Value not found"
    Else
        MsgBox foundRng.Address
    End If

The LookIn property, which I believe your system currently uses xlFormulas (it's xlValuesabove), is the most likely cause of your issue. The formula and value of a cell are the same when it contains a hard value, such as 9999. However, if the formula is =3*3333, the value and the formula diverge, and the number 9999 is not found in the formula.

answered Nov 17 by narikkadan
• 37,660 points

Related Questions In Others

0 votes
1 answer
0 votes
0 answers

What is the formula to keep first two words in a cell over excel?

I want to maintain the first two ...READ MORE

Nov 2 in Others by Kithuzzz
• 20,660 points
23 views
0 votes
1 answer

MS Excel showing the formula in a cell instead of the resulting value

Make sure that... There's an = sign before the formula There's ...READ MORE

answered Nov 8 in Others by narikkadan
• 37,660 points
28 views
0 votes
1 answer

Is there a function in excel to find duplicates

Solution: You can use Conditional formatting inside the ...READ MORE

answered Nov 14 in Others by narikkadan
• 37,660 points
23 views
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,720 points
449 views
0 votes
1 answer

How to load file to Excel Power query from SFTP site

Currently, I don't think there is a ...READ MORE

answered Dec 3, 2018 in Power BI by Upasana
• 8,620 points
2,199 views
0 votes
1 answer

Using VBA Excel to create a gramatically correct list

The Excel AND function is a logical ...READ MORE

answered Feb 9 in Others by gaurav
• 22,040 points
66 views
0 votes
2 answers

How to copy a formula horizontally within a table using Excel VBA?

Hi so basically, create an adjacent column ...READ MORE

answered Feb 16 in Others by Edureka
• 13,640 points
199 views
0 votes
1 answer
0 votes
1 answer

How to stick an embedded document in a specific cell of an excel

Solution Select the documents (you can use the ...READ MORE

answered Oct 18 in Others by narikkadan
• 37,660 points
29 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP