+ Reply to Thread
Results 1 to 17 of 17

Filtering data with textbox value (date)

  1. #1
    Registered User
    Join Date
    04-24-2013
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    57

    Filtering data with textbox value (date)

    Hi all,

    On my userform(FrmKivaDiaari) I have two textboxes for user to write date values if he/she wants to filter data only between those dates. In my example below I am only using start date as example but for some reason not able to make this work. Is there something wrong with Format or why vba does not understand how to filter with this value.
    Lets assume that I have data for every single day for last month. Then, user wants only to show those data lines which have been created on August 18th or after. User writes date to textbox "TxtAlkuPvm" and hits search button. But for some reason every single line of data is filtered out.

    Please Login or Register  to view this content.
    Thank you for your help!
    Ville

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Filtering data with textbox value (date)

    what is the output of your text field?

    are you missing .value?
    FrmKivaDiaari.TxtAlkuPvm.value
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Registered User
    Join Date
    04-24-2013
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: Filtering data with textbox value (date)

    Output? How can I tell the output of a textbox?

  4. #4
    Registered User
    Join Date
    04-24-2013
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: Filtering data with textbox value (date)

    Anyone??? This should be fairly easy to solve.

  5. #5
    Registered User
    Join Date
    04-24-2013
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: Filtering data with textbox value (date)

    Hi again.

    If I use (as below) = instead of >= code works perfectly. Just can't understand why it isn't working!?

    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Filtering data with textbox value (date)

    Quote Originally Posted by torppo View Post
    Output? How can I tell the output of a textbox?
    use debug and watch

    as i have tested your code on sample data


    Please Login or Register  to view this content.
    ps fin date uses . while in Australia we use - or / so the format is the same
    the code works fine as intend so the only thing that is a variable is the output of the form.textbox of which i have no way to debug
    Last edited by humdingaling; 09-02-2014 at 09:37 PM.

  7. #7
    Registered User
    Join Date
    04-24-2013
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: Filtering data with textbox value (date)

    Hi humdingaling,

    I did some further testing and stopped macro after that code line was excecuted. Then I went to see active spreadsheet and found out that there is active filtering in 7th column with right criteria (FrmKivaDiaari.TxtAlkuPvm). BUT, funny thing was that all data has been filtered away. THEN I went to see what kind of filter (I selected: column filter->Date filter->Custom filter) there was for that column and I could see that there is just the filter on place AND after I clicked OK-button data was filtered correctly.
    I just can't understand what's going on with this...

  8. #8
    Registered User
    Join Date
    04-24-2013
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: Filtering data with textbox value (date)

    Anyone with a solution for this??

  9. #9
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Filtering data with textbox value (date)

    as far as i can tell the code should be working correctly

    very hard to see what you are you seeing with the actual file and i'm guessing for reason you cannot share the file

  10. #10
    Registered User
    Join Date
    04-24-2013
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: Filtering data with textbox value (date)

    Hi Hum,

    Unfortunately I cannot share file here but if you would give me your email address I could send you that.

    Ville

  11. #11
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Filtering data with textbox value (date)

    @troppo

    general suggestion:

    make a fake excel file, which containes your problem, without confidential information.

    please also add the desired (expected) result.

    then the forummembers can test the given solutions, and also post it on the forum (the excel file, with the given solution).
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  12. #12
    Registered User
    Join Date
    04-24-2013
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: Filtering data with textbox value (date)

    Hi guys,


    I have attached a sample file. Maybe this time problem will be solved. Write for example day 15.8.2014 in to textbox at Userform and see what happens at Excel file. Filter is on place but for some reason none of the values appear at the spreadsheet.

    Cheers,
    Ville
    Attached Files Attached Files
    Last edited by torppo; 09-18-2014 at 07:31 AM.

  13. #13
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Filtering data with textbox value (date)

    hi Villie,

    Userform code, slightly amended:

    Please Login or Register  to view this content.
    Autofilter code:

    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    04-24-2013
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: Filtering data with textbox value (date)

    Woo hoo watersev! Works like a charm!! Thank you extremely much!

    Cheers,
    Ville

  15. #15
    Registered User
    Join Date
    04-24-2013
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: Filtering data with textbox value (date)

    Oh,

    One more question just popped to my mind. What about if I have two textboxes and I want to filter between those days?

    Ville

  16. #16
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Filtering data with textbox value (date)

    autofilter accepts two criteria with operator And/Or

  17. #17
    Registered User
    Join Date
    04-24-2013
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: Filtering data with textbox value (date)

    Thank you for your reply watersev. Problem solved!

+ 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. Filtering data based on start and end date
    By gururajrao.1992 in forum Excel General
    Replies: 2
    Last Post: 11-28-2013, 02:44 AM
  2. If textbox value = hidden row number then next row - Data Filtering on Userform
    By christopherprater in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-14-2012, 10:55 AM
  3. listbox filtering via textbox
    By nemmi69 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-12-2012, 04:23 AM
  4. Filtering data dependent on the date
    By Neil_Pattison in forum Excel General
    Replies: 1
    Last Post: 10-13-2006, 06:41 PM
  5. Help filtering date related data
    By mgalloway in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-03-2006, 02:40 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