You describe a problem that I will try to solve using the VLOOKUP function, and not using VBA.
You should always consider a solution other than vba first.
Here are some examples of VLOOKUP applications (or SVERWEIS in German, as I know):
http://www.youtube.com/watch?v=RCLUM0UMLXo
http://office.microsoft.com/en-us/excel-help/vlookup-HP005209335.aspx
If you need to do this as a macro, you can use VLOOKUP as an application function - a quick solution with low performance - or you will have to execute the simillar function yourself.
If it should be the last, then you will need more details about your specification regarding performance issues.
You can copy any range into an array, go through this array and check its value, and then copy this value to any other range. This is how I would solve it as a vba function.
It will look something like this:
Public Sub CopyFilter() Dim wks As Worksheet Dim avarTemp() As Variant 'go through each worksheet For Each wks In ThisWorkbook.Worksheets avarTemp = wks.UsedRange For i = LBound(avarTemp, 1) To UBound(avarTemp, 1) 'check in the first column in each row If avarTemp(i, LBound(avarTemp, 2)) = "XYZ" Then 'copy cell targetWks.Cells(1, 1) = avarTemp(i, LBound(avarTemp, 2)) End If Next i Next wks End Sub
Ok, now I have something nice that can come in handy for me:
Public Function FILTER(ByRef rng As Range, ByRef lngIndex As Long) As Variant Dim avarTemp() As Variant Dim avarResult() As Variant Dim i As Long avarTemp = rng ReDim avarResult(0) For i = LBound(avarTemp, 1) To UBound(avarTemp, 1) If avarTemp(i, 1) = "active" Then avarResult(UBound(avarResult)) = avarTemp(i, lngIndex) 'expand our result array ReDim Preserve avarResult(UBound(avarResult) + 1) End If Next i FILTER = avarResult End Function
You can use it in your sheet, for example: FILTER (Tabelle1! A: C; 2) or with = INDEX (FILTER (Tabelle1! A: C; 2); 3) specify the result line. I'm sure someone can extend this to include index functionality in FILTER or know how to return a range as an object - maybe I could, too, but not today;)