Question : How do I populate one spreadsheet from a filtered version of another?

I am attaching a workbook with two worksheets: The first sheet is called "Results (dm)".  When a value for the District Manager is entered in B7, all of the columns in Row 10 are populated with data based on a Vlookup from the second sheet called "Results - All RMs".

What I would like to do is populate all of the rows of data associated with the name of the District Manager that is typed in B7.  

For example, when I type in "Vicky Doe" there should be 12 rows of data that appear on the "Results (dm)" sheet.  See filtered data from  "Results - All RMs" sheet.  
 
Is there code or a formula that will automatically filter the data on the "Results - All RMs" sheet and return all of those results to the "Results (dm)" sheet? The Vlookup formula that I am using now will only return one row of data.

Thank you!

Answer : How do I populate one spreadsheet from a filtered version of another?

The only thing I can do for you at this (with minimal effort) is to use the actual range address, instead of defining them. In a way its a bit of hard coding, but in your case its more dynamic and maybe easier to adjust if need be since its all in the code.:

Sub GetData()
Dim rngCell As Range, rngStart As Range
Dim strManager As String, intCount As Integer
    Application.ScreenUpdating = False
    With Worksheets("Results (dm)")
         '/ Clears the target range
        .Range("$A$10:$AS$500").Clear
        '/ Sets the starting place
        Set rngStart = .Range("$A$10").Offset(-1, 0)
    End With
    '/  Get the item we are looking for
    strManager = Worksheets("Results (dm)").Range("$B$7").Value
    '/ Loop through the data
    For Each rngCell In Worksheets("Results - All RMs").Range("$A$8:$A$500")
        '/  If the name matches
        If rngCell.Value = strManager Then
            '/  Grab the information from each column and copy over
            '/  I am beeing lazy here and just taking data in order. You would have to modify this to get exactly what you need
            For intCount = 0 To 21
                rngStart.Offset(1, intCount).Value = rngCell.Offset(0, intCount).Value
            Next
            '/  move the target range down one for the next item
            Set rngStart = rngStart.Offset(1, 0)
        End If
    Next
End Sub

Leon
Random Solutions  
 
programming4us programming4us