+ Reply to Thread
Results 1 to 15 of 15

TextBox values as filter criteria - dates

  1. #1
    Registered User
    Join Date
    09-19-2013
    Location
    CZE
    MS-Off Ver
    Excel 2010
    Posts
    9

    Question TextBox values as filter criteria - dates

    Hello everyone,

    I have a difficulty to use TextBox Values as criteria for an automated filter... Could anyone of you help me? See the attached file for reference (test.xlsm). I would like users to input dates (from - till) in TextBoxes on UserForm and filter data accordingly. This code works fine with exact text values, but not with dates and "=<":

    Please Login or Register  to view this content.
    I would be grateful for your help. I did not manage that with Google.
    Thank you. Michal

  2. #2
    Registered User
    Join Date
    09-20-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: TextBox values as filter criteria - dates

    The code is working fine for me...only thing you need to ensure is to enter the date in mm/dd/yy format

  3. #3
    Registered User
    Join Date
    09-19-2013
    Location
    CZE
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: TextBox values as filter criteria - dates

    Vivek.jain, thank you for your quick reply. The thing is that nobody in our country can easily understand the mm/dd/yyyy format, because the national standard is dd.mm.yyyy and it would be clumsy to force users to fill in different date-format to UserForm while seeing standard date-formats (dd.mm.yyyy) in the sheets.

    In our localized Excel versions, we never use mm/dd/yyyy. Any idea how to get around this?
    Last edited by MKrop; 09-20-2013 at 04:59 AM. Reason: mistake in format

  4. #4
    Registered User
    Join Date
    09-20-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: TextBox values as filter criteria - dates

    test.xlsmuse the below code on the click event of the ok button.

    Please Login or Register  to view this content.
    Last edited by vivek.jain; 09-20-2013 at 05:42 AM.

  5. #5
    Registered User
    Join Date
    09-19-2013
    Location
    CZE
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: TextBox values as filter criteria - dates

    I appreciate your time you put into this, but I am getting an error in this part of the code now:
    Please Login or Register  to view this content.
    Even in your file you uploaded. Any idea?

  6. #6
    Registered User
    Join Date
    09-20-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: TextBox values as filter criteria - dates

    which version of excel are you using?

  7. #7
    Registered User
    Join Date
    09-20-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: TextBox values as filter criteria - dates

    try using
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    09-20-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: TextBox values as filter criteria - dates

    try using
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    09-19-2013
    Location
    CZE
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: TextBox values as filter criteria - dates

    My Excel version in 2007 now. The problem is probably in A2 and B2, in these 2 cells the #VALUE! error occurs:
    Capture.PNG

    When I run your code in VBA, the UserForm pops-up and after filling some dates (e.g. from 1.1.2013 till 30.5.2013), the macro stops at those 2 lines I mentioned earlier and #VALUE! error in A2 and B2 occurs.

  10. #10
    Registered User
    Join Date
    09-19-2013
    Location
    CZE
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: TextBox values as filter criteria - dates

    (post deleted for duplication)
    Last edited by MKrop; 09-20-2013 at 08:01 AM. Reason: duplication

  11. #11
    Registered User
    Join Date
    09-20-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: TextBox values as filter criteria - dates

    I have written the macro using Excel 2007 and it is working perfectly fine at my end. Can you add break point in your code and step run the code to see if the below formula is converting the date from dd.mm.yyyy format to mm/dd/yyyy format.

    Also note that the input in the text box has to be in dd.mm.yyyy format only...


    Please Login or Register  to view this content.
    Last edited by vivek.jain; 09-20-2013 at 07:59 AM.

  12. #12
    Registered User
    Join Date
    09-19-2013
    Location
    CZE
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: TextBox values as filter criteria - dates

    I have tried many ways, but our Czech dd.mm.yyyy date format is probably cursed. I have not managed to get it working.
    It gets stuck always here:
    Please Login or Register  to view this content.

  13. #13
    Forum Expert Debraj Roy's Avatar
    Join Date
    09-27-2012
    Location
    New Delhi,India
    MS-Off Ver
    Excel 2013
    Posts
    1,469

    Re: TextBox values as filter criteria - dates

    can you please upload sample file..

    in the meanwhile.. try this..

    Criteria1:=">=" & cdate(replace(range("A2"),".","/")), Operator:=xlAnd, Criteria2:="<=" & cdate(replace(range("B2"),".","/"))
    Regards!
    =DEC2HEX(3563)

    If you like someone's answer, click the star to give them a reputation point for that answer...

  14. #14
    Registered User
    Join Date
    09-19-2013
    Location
    CZE
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: TextBox values as filter criteria - dates

    I am lost with this, would appreciate your help.
    Here is the file: test1.xlsm

  15. #15
    Registered User
    Join Date
    09-19-2013
    Location
    CZE
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: TextBox values as filter criteria - dates

    Here is one possible solution in case anyone is interested: Book1.xlsm

+ 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] Filter Listbox Values based on Textbox input
    By redocs in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-17-2013, 04:59 AM
  2. [SOLVED] excel vba filter values to listbox from combobox and save edit values in textbox
    By breadwinner in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-03-2013, 08:42 AM
  3. [SOLVED] Sum values between two dates with certain criteria
    By dmcarthur212 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-21-2013, 02:02 PM
  4. Filter multiple criteria to only keep unique values
    By albardit18 in forum Excel General
    Replies: 2
    Last Post: 05-10-2012, 09:38 AM
  5. Setting criteria between two dates (advanced filter)
    By Chrilliams in forum Excel General
    Replies: 0
    Last Post: 02-08-2011, 12:07 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