+ Reply to Thread
Results 1 to 13 of 13

Advanced Filter

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Advanced Filter

    Hi,

    I am appealing to someone’s better nature to help me adapting a spreadsheet I found on the contextures website (http://www.contextures.com/excelfiles.html#Filter). I love the concept of this and I am trying to create something similar but my skills severely lack.

    Even if you can help me on just one of these problems below I would greatly appreciate it.

    Problem 1:
    Please note that this file contains words associated with movies – If I change the names the model doesn’t work which is the first problem I am stuck with. I need to change the names to the column headings in the perfect sheet

    Problem 2:
    Currently the model only works with two drop down lists – how can I change this to 5 (as in the perfect tab)

    Problem 3:
    I have no idea how to limit the model to include either one or a list of customers, can this be done?


    Sheet Overviews
    Perfect Sheet
    This is ultimately what I am trying to achieve. Here the user can select a customer and a range of fields and the table with update depending on the user selection

    Overview
    This is basically a dump of the information I receive which I am trying to present in a better format

    Movie List
    This will become my overview tab in time

    Select Movies
    This will be the user form in time (I need it to look like the perfect tab)



    Can anyone help in any way – even if you point me in the right direct I will endeavour to solve this. I understand I have a lot of work to do but any help anyone can offer I will be grateful for

    Paul
    Attached Files Attached Files
    Last edited by pauldaddyadams; 11-20-2011 at 04:53 PM.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Complex Advanced Filter

    Hi Paul,

    I wrote some code a while back for a electronics parts guy. I called the file Dell Parts Adv Filter and it (the ideas) might work for your problem.

    It looks like you want to do an advanced filter of your data based on some input. I did this in the attached by double clicking on a sorted list of 3 criteria. If you double click under the Yellow lists it will filter the the results.

    If this type of method works for you, we could try to modify it to you workbook.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Complex Advanced Filter

    I have decided to try (first) adding an additional filter criteria.

    In the attached I have added the option to self year (sheet "select Movies", Cell C7)

    However I can not get the filter to update based on this. I have amended everywhere I thought I had to - can anyone see where I am going wrong?

    The code (I have added in select year)
    Option Explicit
    ' Developed by Contextures Inc.
    ' www.contextures.com
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rngCrit As Range
    
    Set rngCrit = wksCrit.Range("CriteriaRng")
    Application.EnableEvents = False
    
    Select Case Target.Address
        Case Range("SelCat").Address
            rngCrit.Cells(2, 1).Value = Target.Value
        Case Range("SelActor").Address
            rngCrit.Cells(2, 2).Value = Target.Value
        Case Range("SelYear").Address
            rngCrit.Cells(2, 3).Value = Target.Value
    End Select
    
    If Range("SelCat").Value = "" Then
        rngCrit.Cells(2, 1).ClearContents
    End If
    If Range("SelActor").Value = "" Then
        rngCrit.Cells(2, 2).ClearContents
    End If
    If Range("SelYear").Value = "" Then
        rngCrit.Cells(2, 3).ClearContents
    End If
    
    If Not rngCrit Is Nothing Then
      wksMovies.Range("MovieList").AdvancedFilter _
        Action:=xlFilterCopy, _
          CriteriaRange:=rngCrit, _
          CopyToRange:=Range("ExtractMovies"), Unique:=False
    End If
    
    exitHandler:
        Application.EnableEvents = True
        Exit Sub
    errHandler:
        Resume exitHandler
    
    End Sub

  4. #4
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Complex Advanced Filter

    @Marvin P

    That is very similar to what I am trying to achieve. How easy would it be to change it from Double click to a static cell? i.e the user has to select from a drop down list what they want to filter by rather than double click

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Complex Advanced Filter

    Very easy.

    I've used Advanced Filters with a Criterai Range that can hold dropdown values/text. You need to read a little about Advanced Filters and the Criteria so you get your dropdown on the same row under the column headdings. See:
    http://www.contextures.com/xladvfilter01.html or
    http://www.excelfunctions.net/ExcelAdvancedFilter.html
    http://www.ozgrid.com/News/excel-advanced-filter.htm

  6. #6
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Advanced Filter

    Still struggling. I think i know why my CCriterai Range isnt working, its currently looking at B1:C2, how do i delete this named range and then change it to B1:D2?

  7. #7
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Advanced Filter

    Hi,

    It may not be much but i have added 4 selection fields which work

    Is there a way in which I can simply and easily rename or name fields?
    Attached Files Attached Files

  8. #8
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Advanced Filter

    Hi,

    Movie Database works ok with the 4 criterium however Movie Database1 doesnt - everything looks the same to me, can someone identify what the problem is?
    Attached Files Attached Files

  9. #9
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Advanced Filter

    Hi,

    Not sure if anyone is tracking this or not be here goes anyway.

    I am nearly there I hope!!

    I have renammed all the cells and have it nearly working apart from one slight problem.

    One I input in Cell C7 on the customer sheet it should update the CriteriaSel sheet. However it only does so if there is a fileld in Cell C11 - why would this be, I find it strange!!???

    I have attached the model
    Attached Files Attached Files

  10. #10
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Advanced Filter

    Hi Paul,

    Try this. On the Criteria sheet I've done Data Validation and a Macro to do Advanced Filter.
    NOTE - the criteria headings MUST match the data headings (spelling exactly)
    I hope this is what you want.
    Attached Files Attached Files

  11. #11
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Advanced Filter

    Hi,

    Your model does work - is there any way the theory can be applied to my model as i am determined to get mine to work as I think I am close.

    This is my problem:
    On the "customer" tab if you put in cell C3 and entry this entry appears on the "criteriasel" sheet in cell B2

    However if you put an entry on the "customer" tab in cells C7 or C9 it doesnt always appear on the "criteriasel" tab

    any ideas why?

  12. #12
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Advanced Filter

    Can anyone advise me how the entries are made on the "criteriasel" sheet please?

    This is the code if anyone has time to look at it?

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rngCrit As Range
    
    Set rngCrit = wksCrit.Range("CriteriaRng")
    Application.EnableEvents = False
    
    Select Case Target.Address
        Case Range("SelPro").Address
            rngCrit.Cells(2, 1).Value = Target.Value
        Case Range("SelGeo").Address
            rngCrit.Cells(2, 2).Value = Target.Value
        Case Range("SelSpacer").Address
            rngCrit.Cells(2, 3).Value = Target.Value
        Case Range("SelText").Address
            rngCrit.Cells(2, 4).Value = Target.Value
        Case Range("SelGlass").Address
            rngCrit.Cells(2, 5).Value = Target.Value
    End Select
    
    If Range("SelPro").Value = "" Then
        rngCrit.Cells(2, 1).ClearContents
    End If
    If Range("SelGeo").Value = "" Then
        rngCrit.Cells(2, 2).ClearContents
    End If
    If Range("SelSpacer").Value = "" Then
        rngCrit.Cells(2, 3).ClearContents
    End If
    If Range("SelText").Value = "" Then
        rngCrit.Cells(2, 3).ClearContents
    End If
    If Range("SelGlass").Value = "" Then
        rngCrit.Cells(2, 4).ClearContents
    End If
    
    If Not rngCrit Is Nothing Then
      wksMovies.Range("GlassList").AdvancedFilter _
        Action:=xlFilterCopy, _
          CriteriaRange:=rngCrit, _
          CopyToRange:=Range("ExtractData"), Unique:=False
    End If
    
    exitHandler:
        Application.EnableEvents = True
        Exit Sub
    errHandler:
        Resume exitHandler
    
    End Sub
    Last edited by pauldaddyadams; 11-10-2011 at 05:19 AM.

  13. #13
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Advanced Filter

    Hi,
    I'm looking at the first line of your code that starts with PRIVATE meaning the code is behind a worksheet instead in a module. This implies that the code will only work on data on that individual sheet. It will only interact with procedures in that worksheet's module.

    You have a lot of named ranges in your code. Is it possible that one of the named ranges is on another sheet? If so I don't believe a Private routine can deal with ranges outside it's worksheet.

    The correction is to put your code into a module, make it public and jump to it from the event procedure.
    See http://www.cpearson.com/Excel/Scope.aspx or
    http://vbatutor.blogspot.com/2009/02...procedure.html

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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