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
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
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'
Thanks you very mauch, that's great ...