+ Reply to Thread
Results 1 to 25 of 25

Find feature in userform

  1. #1
    Registered User
    Join Date
    08-11-2014
    Location
    london
    MS-Off Ver
    2007
    Posts
    33

    Find feature in userform

    Hi I have a userform which allows me to add,find, and update data in a worksheet.

    When i try to find data by using numbers, such as 100 or so it finds all the entries. But when it comes to trying to find data with dates it says that there is no data matching that date.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Find feature in userform

    Hi rayexcel,

    It looks like you are trying to AutoFilter dates. See post #3 in the following thread which explains the special date format required, and solves a date AutoFilter problem. It includes an example file that you can download: http://www.excelforum.com/excel-prog...ain-point.html

    Lewis

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Find feature in userform

    Dates are stored as numbers in Excel, the dates in your code are text.

    Which part of the code is failing?

    Is it the first part where you are using Find or the second where you use AutoFilter?
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    08-11-2014
    Location
    london
    MS-Off Ver
    2007
    Posts
    33

    Re: Find feature in userform

    None of the code fails, it just returns a 'no data found' msgbox which i created to pop up when no data is there.

    So for my find feature, will converting the the dates in my code to numbers when searching fix this issue?

  5. #5
    Registered User
    Join Date
    08-11-2014
    Location
    london
    MS-Off Ver
    2007
    Posts
    33

    Re: Find feature in userform

    LJMetzger, So i should use the cdbl function?

  6. #6
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,060

    Re: Find feature in userform

    did you try to set yr date (using Format-Format Cells-Custom...) and then type the same format in yr textbox search...
    Regards, John55
    If you have issues with Code I've provided, I appreciate your feedback.
    In the event Code provided resolves your issue, please mark your Thread as SOLVED.
    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    ...enjoy -funny parrots-

  7. #7
    Registered User
    Join Date
    08-11-2014
    Location
    london
    MS-Off Ver
    2007
    Posts
    33

    Re: Find feature in userform

    As in format my dates using vba? Instead of having the sheet already formatted for that column?

    Currently, vba formats it into the short date format, and then the sheet is formatted already for that column in the short date format?

  8. #8
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,060

    Re: Find feature in userform

    it's just a suggestion, I use the same code in one of my file and I just tried to search using Date in textbox, I set the Date in Sheet as i already told you, and it worked. I did not change anything in my code
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    08-11-2014
    Location
    london
    MS-Off Ver
    2007
    Posts
    33

    Re: Find feature in userform

    What kind of variable is rsearch

  10. #10
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,060

    Re: Find feature in userform

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    08-11-2014
    Location
    london
    MS-Off Ver
    2007
    Posts
    33

    Re: Find feature in userform

    Hi this is the code ive attempted to adapt but still get no matches..

    Please Login or Register  to view this content.

  12. #12
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,060

    Re: Find feature in userform

    this is in my file
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    08-11-2014
    Location
    london
    MS-Off Ver
    2007
    Posts
    33

    Re: Find feature in userform

    Still had no luck

    I would upload the file but its too large, even when compressed

  14. #14
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,060

    Re: Find feature in userform

    i upload a test file, perhaps it has a different structure than yours but just see if it helps you
    Attached Files Attached Files

  15. #15
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Find feature in userform

    Try converting the string date in your code to a numeric date so it will match the numeric dates you have on the worksheet.

    You can do that using CLng or DateValue.
    Please Login or Register  to view this content.

  16. #16
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Find feature in userform

    Ray,

    If possible please upload a sample file that contains dates you are trying to match. It is easier to find a solution to a problem like yours, when working with the exact format of what you are searching for.

    To upload a file, click on 'Go Advanced', underneath the reply window. Then click on the 'PaperClip Icon' above, or the 'Manage Attachments' CommandButton below the message window.

    Lewis

  17. #17
    Registered User
    Join Date
    08-11-2014
    Location
    london
    MS-Off Ver
    2007
    Posts
    33

    Re: Find feature in userform

    Hi

    I am either getting an applicaation defined/object defined error, or worksheet defined error.

    with the following code:

    Please Login or Register  to view this content.

  18. #18
    Registered User
    Join Date
    08-11-2014
    Location
    london
    MS-Off Ver
    2007
    Posts
    33

    Re: Find feature in userform

    Heres an examploe
    Attached Files Attached Files

  19. #19
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,060

    Re: Find feature in userform

    see the file attached, it works on my side, the changes are:
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  20. #20
    Registered User
    Join Date
    08-11-2014
    Location
    london
    MS-Off Ver
    2007
    Posts
    33

    Re: Find feature in userform

    Hi John, still same problem, and now the cmbAmend doesn't work either..

    Thanks for the help though, the cmbDelete still works though

  21. #21
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Find feature in userform

    Ray,

    Thanks for uploading the sample file. It was extremely helpful. My working file is attached. I was successful, however there may be additional work required due to the neverending fight between US and European date formats (mm/dd vs dd/mm). I started out by searching for 2/2 (same US and European Formats). When I searched for 1/3 and 3/1 my results were for the incorrect month and day. Hopefully, you will not have the mm/dd reversal problem. If you still have that problem, I may be able to suggest fixes, but I won't be able to test the code, because I am on the wrong side of the pond.

    The following two references can probably explain what I did better than I can. One for .find and the other for AutoFilter with respect to dates.
    'Find (.find) Reference: http://www.ozgrid.com/VBA/find-dates.htm
    'AutoFilter Reference: http://www.ozgrid.com/VBA/autofilter-vba-dates.htm

    To get .find to work, I made the following changes in red. The most important line is the line that contains 'Short Format'.
    Please Login or Register  to view this content.
    There were similar issues with AutoFilter. AutoFilter apparently has issues with European Dates. That is the reason for the two criteria approach to finding a single date. It has the added benefit (side effect) to be able to disregard times, if times were included in the date.
    Please Login or Register  to view this content.
    Lewis
    Attached Files Attached Files

  22. #22
    Registered User
    Join Date
    08-11-2014
    Location
    london
    MS-Off Ver
    2007
    Posts
    33

    Re: Find feature in userform

    Hi LJMetzger

    From trying the userform:
    • I get an error 'Invalid use of null' when I try to select one of the dates for '2/2/2014' listed in my listbox
    • This is listed in the listbox sub and the line highlighted is the line:
    Please Login or Register  to view this content.
    • When I try find something with only one date there it finds and fills the second textbox correctly, but I cant update the values

    The code works, that you added/changed but If im correct you haven't changed the code to the cmbAmend? So it should still work if im correct.

    I think your code for dd/mm is correct and works, aside from in the listbox it displayed dates in the form mm/dd.

    I tried another method, of when the userform loads the column with dates is changed to number format and the userform can find it this way using cdbl, then when the userfom unloads it changes it back to 'short date' format. But when the form unloads the format changes to mm/dd. Would this solution be efficient if I fixed that format mixup?

  23. #23
    Registered User
    Join Date
    08-11-2014
    Location
    london
    MS-Off Ver
    2007
    Posts
    33

    Re: Find feature in userform

    I didnt make my last point clear, the columns changes back to short date format after unloading. But if I have update values then those values changes to mm/dd format. This is likely to how i code the cmbAmend feature.

  24. #24
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Find feature in userform

    It looks like you are trying to put access column 5 of the list box, (.ColumnCount is 6), but we are only putting data in columns 1 and 2.

    Please Login or Register  to view this content.
    I think you are being a little unfair. The original question was 'Find feature in userform' which has morphed into a whole lot more.

  25. #25
    Registered User
    Join Date
    08-11-2014
    Location
    london
    MS-Off Ver
    2007
    Posts
    33

    Re: Find feature in userform

    Sorry thats understandable, I didn't mean to be so. Thanks for the help though very much appreciated

+ 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. Macro that uses the find feature to find a cell and change.
    By Damiantos in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-07-2014, 08:13 AM
  2. [SOLVED] Use the find feature in a macro
    By KLT in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-17-2012, 02:57 PM
  3. Find feature not working
    By mrstinicum in forum Excel General
    Replies: 3
    Last Post: 04-22-2012, 03:40 PM
  4. cannot use find and replace feature
    By mingali in forum Excel General
    Replies: 4
    Last Post: 06-16-2010, 12:48 AM
  5. Replies: 1
    Last Post: 04-27-2009, 08:12 AM

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