+ Reply to Thread
Results 1 to 7 of 7

not sure why find is finding nothing when it should

  1. #1
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    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. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,474

    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. #3
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    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. #4
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

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

    any help with the find command?

  5. #5
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent SAC
    Posts
    8,885

    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.
    Rory

  6. #6
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,570

    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
    Last edited by protonLeah; 04-02-2019 at 07:40 PM.
    Ben Van Johnson

  7. #7
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    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.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Finding a Date with the Find Command
    By dflak in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-21-2017, 12:22 PM
  2. Finding a value then find max value for a range of cells above
    By ewhenth in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-30-2016, 02:18 AM
  3. Find Not Finding!
    By pauldaddyadams in forum Excel General
    Replies: 2
    Last Post: 09-23-2014, 01:13 PM
  4. Find is not finding character string
    By BeginnerVBA in forum Excel General
    Replies: 5
    Last Post: 06-13-2014, 01:32 AM
  5. My Range.Find only finding the first Argument
    By DadaaP in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 06-06-2013, 02:30 PM
  6. Finding data using .Cells.Find
    By GordonPSmith in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-14-2011, 07:28 PM
  7. .Find Not Finding Correct String
    By Mordred in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-22-2011, 02:27 PM

Bookmarks

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