+ Reply to Thread
Results 1 to 7 of 7

Using a Filter within a Macro

  1. #1
    Registered User
    Join Date
    08-30-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    78

    Using a Filter within a Macro

    Hi,

    This is related to a post that was solved for me yesterday.

    Within a recorded macro I'm trying to use a filter on another sheet.

    The criteria to be used on the filter is determined by what a user enters in another cell.


    I've tried to use the macro to copy this cell and paste its contents into the filter but that doesn't work.

    Can anyone tell me how to resolve this issue?

    The user does not have access to the sheet that the filter exists in for privacy reasons.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Using a Filter within a Macro

    Please upload a workbook or a representative cut down copy, anonymised if necessary. It is always easier to advise if we can see your request in its context.

    Show a before and after situation with manually calculated results, explaining which information is data and which is results, and if it's not blindingly obvious how you have arrived at your results some explanatory notes as well.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    08-30-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: Using a Filter within a Macro

    Hi,

    I've attached a cut down version of the file.

    Password to unprotect sheet is "Brutus"

    Password to unprotect workbook is "BrutusSH".


    The first macro is to confirm password. it should copy the users name to row 20.

    The second should pick up the name of the user and apply it to filter in "Team" then copying the ID column in Team to the tab "Costing".

    This is where I'm getting caught. The macro has the name in quotation marks and is not updated by copying the cell in row 20. I'm not sure how to get this filter updated by the user.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    08-30-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: Using a Filter within a Macro

    Hi,

    Can anyone help with this?

  5. #5
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Using a Filter within a Macro

    Try this. I,ve combined both codes into 1. So password check is done and when OK rest of code executes else msgbox to retry.
    Attached Files Attached Files
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  6. #6
    Registered User
    Join Date
    08-30-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: Using a Filter within a Macro

    Thanks bakerman,

    That works perfectly.

    Had hoped to understand how you could do it but I'll have to go and study VB to understand it - needed to do it anyway.

    Again, works beautifully - thanks again.

  7. #7
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Using a Filter within a Macro

    You're welcome and thanks for adding rep points.

+ 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. Macro to filter a pivot whilst looping through filter criteria in a variable list.
    By Alistairm88 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-29-2015, 04:25 AM
  2. [SOLVED] I need formula or macro to filter a number of items from different tables at single filter
    By Karthikeyannb in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-05-2014, 11:04 AM
  3. Need to filter a report filter based on the previous filter
    By elliotencore in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 01-28-2014, 07:44 AM
  4. Replies: 5
    Last Post: 12-19-2013, 06:58 AM
  5. Filter Macro (range contained in filter value)
    By antman10 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-28-2010, 11:09 PM
  6. Advanced Filter Macro - Won't run the filter
    By dsil in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-18-2008, 11:59 AM
  7. Need macro to filter, create tab on filter and copy/paste
    By Jen in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-02-2006, 11:50 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