+ Reply to Thread
Results 1 to 9 of 9

Auto Filter Macro with Two Conditions then Delete Everything Except Condition

  1. #1
    Registered User
    Join Date
    12-22-2020
    Location
    Tampa,FL
    MS-Off Ver
    2019
    Posts
    70

    Auto Filter Macro with Two Conditions then Delete Everything Except Condition

    Hello everyone, I am wanting to add another condition to my Auto-Filter. Currently my filter is simply using one condition which is “SK Subtotal” then it deletes all other rows except the condition.

    I am wanting to add another condition then proceed to delete all other rows that do not meet the conditions. When I try to add criteria2 it seems to not be coming back with my intended result.

    In the attached document I provide a template and another sheet named completed. Completed is the final result that I am wanting the result to be.

    Below is the current Macro that I am using, not sure if we could add on it or if there is better solution.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by cvici; 03-31-2021 at 11:19 AM.

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,078

    Re: Auto Filter Macro with Two Conditions then Delete Everything Except Condition

    How about
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    12-22-2020
    Location
    Tampa,FL
    MS-Off Ver
    2019
    Posts
    70

    Re: Auto Filter Macro with Two Conditions then Delete Everything Except Condition

    Thank you so much..... I saw where I made my mistake. Thank you for your time

  4. #4
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,078

    Re: Auto Filter Macro with Two Conditions then Delete Everything Except Condition

    You're welcome & thanks for the feedback.

  5. #5
    Registered User
    Join Date
    12-22-2020
    Location
    Tampa,FL
    MS-Off Ver
    2019
    Posts
    70

    Re: Auto Filter Macro with Two Conditions then Delete Everything Except Condition

    If I wanted to make one more addition or continue to make additions. Would I use the same rule such as

    Please Login or Register  to view this content.
    Just want to know for future reference?

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,078

    Re: Auto Filter Macro with Two Conditions then Delete Everything Except Condition

    Unfortunately not, unless you are doing an exact match you are limited to 2 criteria.

  7. #7
    Registered User
    Join Date
    12-22-2020
    Location
    Tampa,FL
    MS-Off Ver
    2019
    Posts
    70

    Re: Auto Filter Macro with Two Conditions then Delete Everything Except Condition

    Okay, if I wanted to do 3 how might I construct that code. To keep the same method, meaning delete everything else but Filter "SK Subtotal", "Other Fee SubTotal", and "Transfer Fee".

  8. #8
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,078

    Re: Auto Filter Macro with Two Conditions then Delete Everything Except Condition

    A number of options.
    1) Use an advanced filter instead.
    2) put a formula in the 1st blank column that returns true or false depending on whether that row should be deleted & filter on that.
    3) Use the code to delete 2 values & then repeat it to delete rows with the 3rd value

  9. #9
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hi ! The Sort way ! …


    According to the attachment - and post #7 - a VBA demonstration as a beginner starter
    to paste to the Sheet1 (Example) worksheet module :

    PHP Code: 
    Sub Demo1()
            
    Application.ScreenUpdating False
            
    If FilterMode Then ShowAllData
        With 
    [A1].CurrentRegion.Columns
           
    .Cells(2, .Count 1).Resize(.Rows.Count 1).Formula "=AND(RIGHT(H2,9)<>"" SubTotal"",H2<>""Transfer Fee"")"
           
    .Resize(, .Count 1).Sort .Cells(1, .Count 1), xlAscendingHeader:=xlYes
            V 
    Application.Match(True, .Item(.Count 1), 0)
            If 
    IsNumeric(VThen .Rows(":" & .Rows.Count).Clear
           
    .Item(.Count 1).Clear
        End With
            Application
    .ScreenUpdating True
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !

+ 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] Filter Macro to Delete Everything Except Condition
    By cvici in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-25-2021, 10:10 PM
  2. Auto vlookup and Auto filter based on condition
    By Power Puneeth in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-26-2020, 01:19 PM
  3. Replies: 1
    Last Post: 04-23-2020, 03:44 PM
  4. Need to auto-delete cells based on condition
    By traugotts in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-22-2015, 06:32 AM
  5. Double filter (condition) to delete rows
    By greatalex36 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-24-2014, 07:35 AM
  6. Delete Rows hidden by either Auto Filter and Advanced Filter
    By lesoies in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-05-2013, 10:29 AM
  7. Select/Copy auto filter range with condition
    By jomili in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-26-2010, 01:08 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