+ Reply to Thread
Results 1 to 6 of 6

FIND Method Not Working??

  1. #1
    Forum Contributor
    Join Date
    03-26-2015
    Location
    Cookeville, TN
    MS-Off Ver
    Excel 365
    Posts
    221

    FIND Method Not Working??

    OK, I probably made some really simple mistake here, but I'm not finding it (no pun intended). Trying to use the Range.Find method to find records of contributions within a certain date range. Here is the code:
    Please Login or Register  to view this content.
    StartDate, EndDate, and SearchDate are all declared as Date type. StartDate is set to 12/28/15. EndDate is set to 1/3/16. [ContributionsDates] is a range (of 14 contiguous cells within a single column), all formatted as dates, and with the first 6 cells containing dates (that are either 12/31/15 or 1/1/16). Remaining cells in the range are blank.
    When I manually step through the macro, each time through the loop (for every value of SearchDate, including 12/31/15 and 1/1/16) FoundDate is set to Nothing so it just steps to DateNotFound.
    Why isn't it correctly finding these dates?!?
    Running Excel 2007, by the way.

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,088

    Re: FIND Method Not Working??

    It will be nice to have an EXCEL example.
    When using date the find method is not searching for a value ( Number of days ) but a real date shape "05/10/2015"
    - Battle without fear gives no glory - Just try

  3. #3
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,088

    Re: FIND Method Not Working??

    In addition see an example with UDF

    Please Login or Register  to view this content.
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    03-26-2015
    Location
    Cookeville, TN
    MS-Off Ver
    Excel 365
    Posts
    221

    Re: FIND Method Not Working??

    I'm not believing this... whether FIND can find a certain date value depends on the display format of the searched cells?!? That's insane!
    But sure enough, it's true. If I format my data table to show the dates as "12/31/15" then FIND doesn't find anything. If I format the cells as "12/31/2015" (without changing anything else) then FIND works.

    I wonder what brainiac at Microsoft decided to program it this way (and, of course, not explain this in the reference material)? Makes no sense to me, but THANKS for helping me figure it out!

  5. #5
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: FIND Method Not Working??

    Date are a different kettle of fish, that is why you should be converting them with DateSerial.

    eg,

    Please Login or Register  to view this content.
    EDIT and if you do need to search a date it shoud be like this,

    Please Login or Register  to view this content.
    Be fore warned, I regularly post drunk. So don't take offence (too much) to what I say.
    I am the real 'Napster'
    The Grid. A digital frontier. I tried to picture clusters of information as they moved through the computer. What did they look like? Ships? motorcycles? Were the circuits like freeways? I kept dreaming of a world I thought I'd never see. And then, one day...

    If you receive help please give thanks. Click the * in the bottom left hand corner.

    snb's VBA Help Files

  6. #6
    Forum Contributor
    Join Date
    03-26-2015
    Location
    Cookeville, TN
    MS-Off Ver
    Excel 365
    Posts
    221

    Re: FIND Method Not Working??

    Actually, it looks like dates aren't the only type of data where FIND is format-sensitive.

    After fixing the date problem, the next chunk of code (that used FIND to search for a record number) didn't work either! My record numbers were all formatted to display 5 digits (such as 00017), to distinguish them from other data. When I reformatted that column of cells to General format, then FIND worked.

+ 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. find method stopped working after formating cells
    By kmeld in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-13-2013, 03:49 AM
  2. [SOLVED] Find method not working as (I) expected
    By bd528 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-09-2012, 11:24 AM
  3. VBA find method and named range not working
    By frankienap in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-31-2012, 09:46 AM
  4. find method fails to find custom format date
    By yot68 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-03-2012, 06:28 PM
  5. "FIND" method Macro not working
    By TRJJK73 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-15-2008, 01:23 AM
  6. Find Method not working any more
    By Caligula in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-29-2007, 04:05 PM
  7. Find Method not working
    By doodle in forum Excel General
    Replies: 5
    Last Post: 04-27-2006, 04:45 PM
  8. Find Method Stops Working in Excel 2000
    By nfk in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-14-2005, 03:31 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