• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Extraction problem

Villalobos

Active Member
Hello,

I would like to ask that tow to extract only those materials from sheet Data (the data stored in table) to sheet Extraction which are classed as 7920?

This code is extract all columns but I need only the materials (classed as 7920).

Code:
Sub Extract()
Sheets("Extraction").Range("E8").CurrentRegion.Clear
Sheets("Data").Range("Táblázat1[#All]").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:= _
Sheets("Data").Range("L8:L9"), CopyToRange:=Sheets("Extraction").Range("E8"), Unique:=True
Sheets("Extraction").Activate
Sheets("Extraction").Range("E8").Select
End Sub

The sample file is attached to this thread.

Could somebody give me some advice?

Many thanks in advance!
 

Attachments

  • sample.xlsm
    22.5 KB · Views: 0

Hi !

Advanced filter is the right way.

Attach a sample .xlsx workbook (no code) with a source worksheet
and a desired result worksheet …
 
Code:
Sub Demo()
Dim Ws As Worksheet
Set Ws = Worksheets("Extraction")
    Ws.[B8].CurrentRegion.Clear
Application.ScreenUpdating = False

With Worksheets("Data")
    .[E8].CurrentRegion.AdvancedFilter xlFilterInPlace, .[L8:L9], , True
    .[_FilterDatabase].Columns(1).Copy Ws.[B8]
    .ShowAllData
End With

Ws.Activate:  Set Ws = Nothing
End Sub

Do you like it ? So thanks to click on bottom right Like !

I don't use Range("Táblázat1[#All]") 'cause now I'm under Excel 2003
and this code style works from the 2007 version …
 
Back
Top