# not sure why find is finding nothing when it should

1. ## not sure why find is finding nothing when it should

so im searching the current workbook and worksheet (but i eventually want to search the whole folder) for a text string ("this is a test") found in cell A20. here is my code snippet:

``Please Login or Register  to view this content.``
what am i not understanding on how to use the find command?

2. ## Re: not sure why find is finding nothing when it should

From what it looks like, you have the code searching A20 for the string "this is a test" and only A20. You need a bigger range if you want to search a bigger range.

3. ## Re: not sure why find is finding nothing when it should

actually that is by design. i have three area's that i MIGHT want to search for. the description (only cell A20), the item (cells B23 - B39) and the item description (cells E23 - E39). so here is the whole code so you can see.

``Please Login or Register  to view this content.``
so first question is how to search just one cell. second is how to search through a range of cells. how can this be fixed?

4. ## Re: not sure why find is finding nothing when it should

any help with the find command?

5. ## Re: not sure why find is finding nothing when it should

You could just use Countif for this. Your code currently makes no sense as it just loops infinitely if you find the value.

6. ## Re: not sure why find is finding nothing when it should

``Please Login or Register  to view this content.``

Range.Find is looking for an unknown cell with a particular value among multiple cells. A20 is a single known cell and you want to examine its contents...

Set c = .Find("this is a test", after:=rng, LookIn:=xlValues)
Debug.Print "made it to here 1"

If Not c Is Nothing Then
'c' starts off as Nothing/empty. When the search parm is found, it is no longer Nothing so now "NOT" c is nothing

7. ## Re: not sure why find is finding nothing when it should

thanks @protonLeah, that got me over the hump. here is my finished code, working good.

``Please Login or Register  to view this content.``
what do you think.

There are currently 1 users browsing this thread. (0 members and 1 guests)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1