Hi, I have the following code that searches for data based on what i
type in it (in this case it is "FHCX") and posts it in a new sheet.
How can i get excel to read a menu with selections using "X" in a cell
and feed it into the code below to produce results on a new tab?

Sub ServiceReport()
    ' Copy the selected range to the Report worksheet
    Dim WSD As Worksheet ' Data worksheet
    Dim WSR As Worksheet ' Report worksheet

    Set WSD = Worksheets("Data")

    ' Add a new worksheet to this workbook
    Set WSR = Worksheets.Add(after:=Worksheets("Data"))

    ' Rename the new worksheet & set up titles
    WSR.Name = "Service"
    WSR.Cells(1, 1) = "Service Report"
    WSR.Cells(1, 1).Font.Size = 14

    WSD.Range("A1:E1").Copy Destination:=WSR.Cells(3, 1)
    NextRow = 4


    ' Loop through all records on WSD
    FinalRow = WSD.Cells(Rows.Count, 1).End(xlUp).Row
    For i = 2 To FinalRow
        If WSD.Cells(i, 2) = "FHCX" Then
            ' Copy this record to the next row on WSR
            WSD.Cells(i, 1).Resize(1, 5).Copy
Destination:=WSR.Cells(NextRow, 1)
            NextRow = NextRow + 1
        End If
    Next i

    ' Make sure WSR is the active sheet
    WSR.Select

    ' Report that the macro is done
    MsgBox Prompt:=NextRow - 4 & " service records copied to the
service report."

End Sub

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
Like our page on facebook , Just follow below link
http://www.facebook.com/discussexcel

Reply via email to