Link to home
Start Free TrialLog in
Avatar of kbay808
kbay808Flag for United States of America

asked on

How to use VBA to copy a range where the value in column meets a criter

I have a table on one sheet, but I need to show the related records for an ID on another sheet.  On the attached file on the Ticket Viewer sheet you can select an ID number from the dropdown in cell B1.  When an ID is selected, I need all of the data that matches that value on the Report 1 sheet in column A to populate below the headers in row 3.  


Private Sub Worksheet_Change(ByVal Target As Range)

' Update/Audit Passed btns
If Not Intersect(Target, Range("B1")) Is Nothing Then
    If Range("B1").Value <> "" Then
        'Need to add code to copy data from the Report 1 sheet
    Else
        Range("A4:H100").ClearContents
    End If
End If
End Sub
Ticket-Viewer.xlsm
Avatar of Rob Henson
Rob Henson
Flag of United Kingdom of Great Britain and Northern Ireland image

Unfortunately can't download a file with macros for security but would suggest you take a look at Advanced Filter.

This gives the option of copying the results of a filter to another location. It can be incorporated into a VBA routine that clears previous filter and copies the new data.
ASKER CERTIFIED SOLUTION
Avatar of Fabrice Lambert
Fabrice Lambert
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kbay808

ASKER

Thank you very much