Find Just Doesn't Work....

cicconmr

Board Regular
Joined
Jul 5, 2011
Messages
90
Does any one else have this problem where your find routine works some times but not others....even when you test it by searching for the same thing? Is this a common error...I could not find anything on it.

This sheet is for other people to use and it really is sad when I get emails that the find doesn't work all the time.....
 
xlPart is not a duct tape fix job. xlPart works when you want to search part of a value in a cell. xlWhole works when you want to match the entire contents of the cell.

I want to find, say T, using LookAt:= xlWhole

This is because some tickers for stocks have T's in them, but aren't ATT the company I want. However....even though I'm sitting here looking at letter T it skips to my Error Sub.

If you want ATT followed by a space search for that with xlPart if the cell contains other text with it.
 
Upvote 0

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Having the Problem again, there are no trailing spaces so I'm guessing hte problem is with my for loop and not my Find Method. Any thought?? This is really frustrating becuase there's no reason this should not work from what I can see.....

Code:
Search:
    Symbol = InputBox("Please Enter the company symbol WITHOUT spaces.")
    On Error GoTo Error
    For Each ws In Worksheets
        If ws.Name <> "Summary" Then
                Set Found = ws.Columns("A").Cells.Find(What:=Symbol, After:=ActiveCell, LookIn:=xlValues, LookAt:= _
                    xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
                    False, SearchFormat:=False)
                If Not Found Is Nothing Then
                    Application.Goto Reference:=Found
                    Exit Sub
                End If
        End If
    Next ws
 
Upvote 0
No Luck, it simply does not find anything, goes straight to my error handler, is my error handler in the wrong place?
 
Upvote 0
Okay I think that must have been it, I moved the error handler to the bottom, before it went back through the loop, and now it works. Does that make sense? I don't know why it would have been registering an Error right after the InputBox?
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,328
Members
452,907
Latest member
Roland Deschain

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top