Consulting

Results 1 to 7 of 7

Thread: Macro to run advanced filter

  1. #1

    Macro to run advanced filter

    Please see attached workbook as this isn't easily explained without a visual aid.

    Using 'advanced filter' I would like a sub routine to take any data specified on the "filters" worksheet inside the box B5:P26 (which is also duplicated further over) and use this ascriteria for advanced filtering the data on "Customers" current range; A6:AT29 (List range).

    The problem I have is that I need the flexibility to potential use all fields for criteria or just one if the others are blank, I cannot use auto-filters as this will be used in excel 2003 where there is a max of 3 criteria and would like this macro to create a friendly UI.

    Apologies if I haven't made the problem clear, please ask me to clarify if so.

    Any help or advice would be highly apprciated as I've been going around in circuls on this for days.

    Many thanks in advance.
    Attached Files Attached Files

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Welcome to VBAX
    I've removed your formulae and used a change event to add the criteria to the range. This will only work on one criteria row. If you need multiple lenders etc. this would need refinement.
    Attached Files Attached Files
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    Thank you so much for your response and time mdmackillop. You're right, I will need to adapt this for +1 line per field but this is a huge improvement on the amateurish code I had fiddled together myself.

    You are indeed a wizard!

  4. #4
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Consider a Userform for data entry. Here's a simple example.
    Attached Files Attached Files
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5

    Form code

    A form to collect the criterion makes much more sense, I have attempted to reprogram for the additional fields but can't seem to get this to work, I'm not sure how to integrate the second list box.
    Attached Files Attached Files

  6. #6
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Not a bad attempt.
    Use descriptive names for controls (especially if you have a lot of them).
    Try to order consistently. It makes it easier to maintain or spot errors.
    Attached Files Attached Files
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  7. #7
    Thank you ever so much for your help, and sorry for the very late reply. I had posed the problem elsewhere before hand with no response. I bow to your knowledge and generosity and hope this example can help others.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •