+ Reply to Thread
Results 1 to 14 of 14

Dynamic Advanced Filter Refreshing

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-30-2014
    Location
    USA
    MS-Off Ver
    Version 14.4.3, Mac 2011
    Posts
    145

    Dynamic Advanced Filter Refreshing

    So I'm working on a fun little database where my search bar is also my data entry bar. I'll worry about the data entry later, but I'm looking to filter pretty dynamically the data I put in.
    The code I'm posting is wrong, but it was my first shot!
    Is it possible to set the criteria to not be absolute? Shoot, how do I put this... =*"Giant"*? So if there is a cell somewhere in the data that says "Big Giant File" I would like the typed criteria of "Giant" to show the row with "Big Giant File"! As it is I think I would have to start with "Big" to find such a cell.

    I'm also trying to get this to update with every typed change! This is presenting a lot of issues as I have very little idea of what I'm doing but I'm convinced it isn't all too complicated. My file is very easy to read! Only one sheet :D take a look!

    New Database 6.18.15.xlsm

    Private Sub Worksheet_Change(ByVal Target As Range)
        With Sheets("Sheet1")
            .AutoFilterMode = False
                    With .Range("B10:M" & .Cells(Rows.Count, 2).End(xlUp).Row)
                        .AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
                            Range("B3:M4"), Unique:=False
                    End With
        End With
        Range("A1").Select
    End Sub
    Thanks a lot for taking a stab at it guys!
    Red

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Dynamic Advanced Filter Refreshing

    Which is the changing cell on which the event to trigger.

    Currently the event will run on each cell change.

    Also which cell entry this text refers to *"Giant"*?

    May be try this "*Giant*"


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Contributor
    Join Date
    07-30-2014
    Location
    USA
    MS-Off Ver
    Version 14.4.3, Mac 2011
    Posts
    145

    Re: Dynamic Advanced Filter Refreshing

    Quote Originally Posted by :) Sixthsense :) View Post
    Also which cell entry this text refers to *"Giant"*?
    Ideally it would be any cell within B4:M4 <- the search/input bar in teal.

    Quote Originally Posted by :) Sixthsense :) View Post
    May be try this "*Giant*"
    Haha yes, the only thing is, doing it via code that is looking at the input of any cell in B4:M4, I'm not looking for specifically *Giant* every time, I'm wondering if the way to do find words within text in a general advanced filter code such as this isn't possible.

  4. #4
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    365 Version 2505
    Posts
    2,790

    Re: Dynamic Advanced Filter Refreshing

    I had some success with this. It doesn't work with the client code, so I put in a different filter for B4. It might have issues with the dates too, but it works good on the text columns. I'm too tired to mess with it any more tonight.

    Good Luck.

    Here's a cool site if you want to learn some good stuff.
    Autofilter.

    Private Sub Worksheet_Change(ByVal Target As Range)
    
    If Target.Count > 1 Then Exit Sub
    
    If Intersect(Worksheets("Sheet1").Range("B4:M4"), Target) Is Nothing Then Exit Sub
    
    If Target.Address = "$B$4" Then
        With Sheets("Sheet1")
            .Range("B10:M" & .Cells(Rows.Count, 2).End(xlUp).Row) _
            .AutoFilter Field:=Target.Column - 1, Criteria1:=Target.Value
        End With
    Exit Sub
    End If
    
    Dim FilterCriteria as string
    FilterCriteria = "*" & Target.Value & "*"
    
    With Sheets("Sheet1")
        .Range("B10:M" & .Cells(Rows.Count, 2).End(xlUp).Row) _
        .AutoFilter Field:=Target.Column - 1, Criteria1:=FilterCriteria
    End With
        
    End Sub

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

    Re: Dynamic Advanced Filter Refreshing

    you want to auto add the "*" on what you type in?
    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.

  6. #6
    Forum Contributor
    Join Date
    07-30-2014
    Location
    USA
    MS-Off Ver
    Version 14.4.3, Mac 2011
    Posts
    145

    Re: Dynamic Advanced Filter Refreshing

    Quote Originally Posted by skywriter View Post
    I had some success with this. It doesn't work with the client code, so I put in a different filter for B4. It might have issues with the dates too, but it works good on the text columns. I'm too tired to mess with it any more tonight.
    Autofilter.
    Thanks a ton sky as always. Your code is always so beyond my basic understanding, I'm looking at the link and understand so little as of now but thank you! :D
    Yes for numbers/dates it doesn't seem to work and then it does the classic hiding of the data that I was trying to get rid of before. This is starting to get really interesting and it isn't even the hardest part of the sheet XD

    Quote Originally Posted by humdingaling View Post
    you want to auto add the "*" on what you type in?
    I think so (at least for the text cells not for the number/dates?)
    Sky wrote up a nice solution for texts which works well with the target.value aspect of the worksheet_change so that might not be the biggest problem.
    If you open up the document and try out some of the code here you'll see that there are some strange behaviors like permanent hidden rows, exposed filter buttons, selected ranges, that I'm trying to square away and clean up. I will eventually be giving this workbook to people with very little excel experience past the =SUM formula so I want to eliminate the need to run a application.enableevents = TRUE macro trying to figure out what has gone wrong XD

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

    Re: Dynamic Advanced Filter Refreshing

    i tinkered with advanced filters and i could never figure a way to make it work without physically written onto the sheet itself to make range work
    if you dont want the criteria to show on sheet itself i would stick to autofilter

    as mentioned
    numbers/dates work differently

    IMO advanced filter should be use when you are replacing destination or eliminating duplicates or requiring a very complex set of criteria
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    07-30-2014
    Location
    USA
    MS-Off Ver
    Version 14.4.3, Mac 2011
    Posts
    145

    Re: Dynamic Advanced Filter Refreshing

    Well that code is absolutely beautiful. I tried editing it to allow me to do something different and it just went back to closing up rows and being stubborn.

    Because I want to use the search box as a data entry box later, I want to keep the *s out (even though I could do a cut one forward one backwards on each value when I paste it in lated but ehh :/)

    What I was trying to do was copy the values of rows 3 and 4 to rows 5 and 6. For B6 I was going to do
    =IF(B4="","","*"&B4&"*")
    And drag that to M
    Then I had went to your private sub and got rid of your Len(Target.Value) section for placing "*"s around the values (extremely cool by the way) and changed the criteria range to B5:M6.
    It utterly failed and I have no idea why.

    But your code makes the screen beautiful to look at, now odd selection ranges happening post filter, I just need to keep the search bar itself without extra symbols so I can submit data into the list below from it as well in the future. Any thoughts?

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

    Re: Dynamic Advanced Filter Refreshing

    firstly with your clear button
    need to insert reset advanced filter code in there as well
    Sub Clear()
    ' Clears the search/input row
        Application.EnableEvents = False
        Range("B4:M4").ClearContents
        Application.EnableEvents = True
        With ActiveSheet
            If .FilterMode And Not .AutoFilterMode Then
                .ShowAllData
            End If
        End With
        
    End Sub
    worksheet change wont know the difference between data entry and searching so you are going to have conflicts if you want it to search and data entry without both being triggered manually (ie with subroutine via button most likely)

    if you are going to trigger it via button then things become slightly less complicated

  10. #10
    Forum Contributor
    Join Date
    07-30-2014
    Location
    USA
    MS-Off Ver
    Version 14.4.3, Mac 2011
    Posts
    145

    Re: Dynamic Advanced Filter Refreshing

    Thank you for taking the initiative and looking a step further with the clear button! I stuck a .screenupdating = false/true in there to make sure there is no selection happening.

    I also edited the sheet and private sub so that this is in there instead

        If Len(Target.Value) > 0 Then
            Application.EnableEvents = False
            Cells(Target.Row + 2, Target.Column) = "*" & Target.Value & "*"
            Application.EnableEvents = True
        Else
            Application.EnableEvents = False
            Cells(Target.Row + 2, Target.Column) = ""
            Application.EnableEvents = True
        End If
    This way I have two rows below with the same title (set there) and an updated *text* which gets read instead of the actual search bar. Now I can think about making that submit data!

    I don't mind at all having the worksheet change running while inserting the data :D
    I fully expect that typing in a brand new entry will leave the filter section blank, and simply add the entry to the last row. Then after pressing clear, all rows will show again with that data included!

    The data entry gets a bit complicated, and I avoided using a separate sheet for the data because I wanted to be able to edit the data right then and there. This makes me wonder if I should set the sheet to update when editing the data too.

    Still have to think about how to make a filter/sorting ability for client dates :/

    I'll post back with some conceptual steps moving forward! Thanks so far!
    Last edited by RedSummer; 05-18-2015 at 01:50 PM.

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

    Re: Dynamic Advanced Filter Refreshing

    if you are going to persist with this line of working then i suggest you work with Autofilter like skywriters suggestion instead of advanced filter
    you can embed "coding" (adding things to criteria like *) into the filter much easier than advanced filter can

    the link Sky provided does have quite a few nifty tips on coding

  12. #12
    Forum Contributor
    Join Date
    07-30-2014
    Location
    USA
    MS-Off Ver
    Version 14.4.3, Mac 2011
    Posts
    145

    Re: Dynamic Advanced Filter Refreshing

    Do you think that would help with searching numbers and dates?
    It's hard to change when you've given me something so good haha but I know that you are right

  13. #13
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    365 Version 2505
    Posts
    2,790

    Re: Dynamic Advanced Filter Refreshing

    Quote Originally Posted by RedSummer View Post
    Do you think that would help with searching numbers and dates?
    It's hard to change when you've given me something so good haha but I know that you are right
    With text I think it's not unusual to want to type a partial word and get matches, but with dates you don't usually search by typing a partial date like 11/1, you go for something before or after or between two dates. What are you looking to do with the dates and other numbers? Type a partial number or partial date and have matches come up?

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

    Re: Dynamic Advanced Filter Refreshing

    as sky mentioned

    Text - no issues
    Dates = depends on what you want to enter and what you expect as filter...potentially manageable
    i have left it unfinished

    Numbers = contains number is actually one of the harder things to replicate, i did a work around using CF and then filter color

    anyway you will see what i did
    Attached Files Attached Files

+ 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] Advanced Filter to Dynamic Range
    By John in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-13-2019, 12:06 AM
  2. Advanced filter with dynamic critieria range
    By kilvan99 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-14-2014, 02:29 PM
  3. Advanced filter a dynamic date range
    By oneandoneis2 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-06-2006, 03:57 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