Consulting

Results 1 to 3 of 3

Thread: filtering data from two or more sheets

  1. #1
    VBAX Regular naris's Avatar
    Joined
    Jul 2008
    Posts
    34
    Location

    Thumbs up filtering data from two or more sheets

    I have a macro to filtering data from two or more sheets in the result sheet, I hope this macro will useful for you.
    And I hope someone want revised this macro become simplest macro script.

    Thanks you.
    Naris

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Naris,
    Make use of Variables to store ranges. It makes the code more flexible.

    [VBA]
    Option Explicit
    Sub Filter2()
    Dim wsRes As Worksheet
    Dim i As Long
    Dim FRange As Range
    Dim CrRange As Range
    Dim Tgt As Range
    Set wsRes = Sheets("Result")
    Set CrRange = wsRes.Range("B1:B2")
    For i = 2 To Sheets.Count
    Set Tgt = wsRes.Cells(Rows.Count, 1).End(xlUp).Offset(2)
    Tgt.Value = "Result " & i - 1
    With Sheets(i)
    Set FRange = Range(.Cells(1, 1), .Cells(Rows.Count, 1).End(xlUp)).Resize(, 3)
    FRange.AdvancedFilter Action:=xlFilterCopy, _
    CriteriaRange:=CrRange, CopyToRange:=Tgt.Offset(1), Unique:=False
    End With
    Next
    End Sub

    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Regular naris's Avatar
    Joined
    Jul 2008
    Posts
    34
    Location
    Thanks you very mauch, that's great ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •