+ Reply to Thread
Results 1 to 9 of 9

Issue With Certain Dates Not Being Recognised When Searching

  1. #1
    Registered User
    Join Date
    02-13-2020
    Location
    hull, england
    MS-Off Ver
    2007
    Posts
    32

    Issue With Certain Dates Not Being Recognised When Searching

    Hi

    I have a range of dates which I have VBA search through using a command button to find the cell that contains a specific date Im looking for - a date picked from a calendar user-form and placed in a text box. The
    The format of the date in the text box is the same as the format of the range, i.e. dd-mmm (or for example 11-feb), and the code instructs VBA to search the cell value.
    However this is where I am confused. On searching I can find any date but only those after the 10th of the month, for example 10th, or 17th, or 22nd. But it fails to recognise anything between 01-09. Why is this and is there any solution?

    The code from the calendar to the textbox is:

    Please Login or Register  to view this content.
    and the code to search in command button is

    Please Login or Register  to view this content.
    This is a works project and was going good until this problem which has brought me to a complete standstill for the last two days. Any help would be gratefully received

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Issue With Certain Dates Not Being Recognised When Searching

    Hello el-paso,

    Welcome to the forum!

    The problem is the value in the TextBox is not a Date. It is just an alphanumeric representation of the date, as far as the computer is concerned. You need to convert the text back to a Date the computer can recognize. The bold section in the code does this.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    02-13-2020
    Location
    hull, england
    MS-Off Ver
    2007
    Posts
    32

    Re: Issue With Certain Dates Not Being Recognised When Searching

    Thanks Leith Ross, your solution still refused to acknowledge the dates however your answer did inspire me to make some changes and bingo, sorted.
    Basically I changed the calendar code for the date format to dd/mm/yyyy and changed the search code to look in formulas.
    Thankyou for taking the time to help me.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Issue With Certain Dates Not Being Recognised When Searching

    Hello el-paso,

    You're welcome. I am glad you were able to solve the issue. Good work!

  5. #5
    Registered User
    Join Date
    02-13-2020
    Location
    hull, england
    MS-Off Ver
    2007
    Posts
    32

    Re: Issue With Certain Dates Not Being Recognised When Searching

    OMG now Iv discovered another problem!!!!
    Every date Iv tested is working fine apart from 01/01/2020, which for some reason is jumping to 01/11/2020.
    Whats going on??

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Issue With Certain Dates Not Being Recognised When Searching

    Hello El-paso,

    Can you post a copy of your workbook?

  7. #7
    Registered User
    Join Date
    02-13-2020
    Location
    hull, england
    MS-Off Ver
    2007
    Posts
    32

    Re: Issue With Certain Dates Not Being Recognised When Searching

    Have attached an upload. Its in its most basic form while I iron out these creases
    Last edited by el-paso; 02-14-2020 at 01:19 PM.

  8. #8
    Registered User
    Join Date
    02-11-2014
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Issue With Certain Dates Not Being Recognised When Searching

    Hello el-paso

    Quote Originally Posted by el-paso View Post
    OMG now Iv discovered another problem!!!!
    Every date Iv tested is working fine apart from 01/01/2020, which for some reason is jumping to 01/11/2020.
    Whats going on??

    Your choice of xlFormulas for the LookIn parameter is an excellent choice for finding a date. With the FIND command, don't forget to also specify the value of the LookAt parameter and the value of the After parameter.

    Replace
    Please Login or Register  to view this content.
    by
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    02-13-2020
    Location
    hull, england
    MS-Off Ver
    2007
    Posts
    32

    Re: Issue With Certain Dates Not Being Recognised When Searching

    cheers docmarti for it to be something so simple as the lookat feature!

+ 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] Macro not filtering between recognised dates
    By Ochimus in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-10-2018, 10:45 AM
  2. Imported data dates recognised as numbers
    By IJY14 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-17-2018, 04:42 PM
  3. [SOLVED] Some dates not recognised accurately in excel
    By RuthieBuxton in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 07-27-2018, 09:21 AM
  4. Replies: 5
    Last Post: 10-19-2015, 10:56 AM
  5. [SOLVED] Dates recognised when recording Macro, but not recognised when running it.
    By Ochimus in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-21-2015, 10:19 AM
  6. [SOLVED] Dates copied from webpage not recognised by excel
    By juansn in forum Excel General
    Replies: 5
    Last Post: 11-08-2013, 06:36 AM
  7. Searching for Common Respondents Over Multiple Years (Duplicate Value Issue)
    By juliaranauro in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-13-2013, 10:05 AM

Tags for this Thread

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