+ Reply to Thread
Results 1 to 10 of 10

Using Advanced Filter to Extract data from certain Columns

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2024
    Posts
    2,888

    Re: Using Advanced Filter to Extract data from certain Columns

    I managed to resolve the issue

    See my code below

     Sub ExtractDataWithAdvancedFilter()
       
        Dim wsImport As Worksheet, wsExtract As Worksheet
        Dim criteriaRange As Range, copyToRange As Range
        Dim lastRow As Long
    
        ' Set references to the sheets
        Set wsImport = ThisWorkbook.Sheets("Imported Data")
        Set wsExtract = ThisWorkbook.Sheets("Extract Specified Cols")
    
        ' Clear existing data in wsExtract from row 2
        wsExtract.Range("A2:E" & wsExtract.Rows.Count).ClearContents
    
        ' Define the range for criteria (AA1:AA2 in wsExtract)
        Set criteriaRange = wsExtract.Range("AA1:AA2")
    
        ' Determine the last row of data in wsImport
        lastRow = wsImport.Cells(wsImport.Rows.Count, 1).End(xlUp).Row
    
        ' Define the range where the filtered data will be copied to (A1:E1 in wsExtract)
        Set copyToRange = wsExtract.Range("A1:E1")
    
        ' Apply the advanced filter
        wsImport.Range("A1:G" & lastRow).AdvancedFilter Action:=xlFilterCopy, _
            criteriaRange:=criteriaRange, copyToRange:=copyToRange, Unique:=False
    End Sub
    Attached Files Attached Files

+ 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] Advanced Filter to extract data from sheets 2 onwards
    By Howardc1001 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 03-07-2022, 09:53 AM
  2. [SOLVED] Advanced FILTER Function to Extract Data Subject to Conditions
    By andrewc in forum Excel General
    Replies: 7
    Last Post: 02-02-2022, 03:55 AM
  3. [SOLVED] VBA to Extract Data using advanced Filter
    By Howardc1001 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-26-2019, 10:01 AM
  4. Advanced Filter Extract Range Error
    By rob_h in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-30-2019, 06:50 PM
  5. Extract data using Advanced Filter and VBA
    By vadivel77 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-08-2015, 12:22 PM
  6. [SOLVED] Advanced Filter - extract data to new sheet
    By schnautza in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 01-28-2014, 02:43 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