+ Reply to Thread
Results 1 to 2 of 2

Advanced Filter Macro

Hybrid View

  1. #1
    Registered User
    Join Date
    08-11-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    17

    Advanced Filter Macro

    Hi

    I have a list of records with one colomn, column F listing the type of record, each assigned a letter.

    I need to filter all records with B, C, J, M, O and move all those records to a new sheet (Sheet2) and delete from original sheet ("Data")

    Many thanks

  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: Advanced Filter Macro

    Hi

    Create a list which contains the column header of your B,C,J etc records, and list the B,C;J underneath and name the whole range 'crit'

    Name the whole of your data 'data' and include the filed headings.

    Now run the following macro

    Sub FilterCopyDelete()
        Range("Data").AdvancedFilter Action:=xlFilterInPlace, criteriarange:=Range("crit")
        Range("Data").Offset(1, 0).Resize(Range("data").Rows.Count - 1).SpecialCells(xlCellTypeVisible).EntireRow.Copy
        Sheets.Add
        Range("A1").PasteSpecial (xlPasteAll)
        Range("Data").Offset(1, 0).Resize(Range("data").Rows.Count - 1).SpecialCells(xlCellTypeVisible).EntireRow.Delete
        Range("Data").AutoFilter
    
    End Sub
    HTH
    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.

+ 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