Copy rows that meet criteria from 2 sheets into a new sheet

Sparkee

New Member
Joined
Aug 24, 2017
Messages
11
Office Version
  1. 365
Platform
  1. Windows
Hi, I have 2 sheets with data downloaded. I have cross-referenced them and have "yes" and "no" results in Column A in each sheet. I am trying to copy rows with "yes" in column A. I need them to be separate macros because I will have another macro to tidy up the data from "DSS download" table before bringing in the second set of data. The first macro is working, the second macro is working but I need it to put the data at the end of the existing data in "Results"

Code:
Option Explicit

Sub UpdateDSSEntries()
Dim wsA As Worksheet:   Set wsA = Sheets("Results")
Dim wsD As Worksheet:   Set wsD = Sheets("DSS download")

'clear the Results
    wsA.UsedRange.ClearContents
    
'Use the autofilter to grab all audit entries from data sheet
    With wsD
        .AutoFilterMode = False
        .Range("A:A").AutoFilter
        .Range("A:A").AutoFilter Field:=1, Criteria1:="yes"
        .UsedRange.SpecialCells(xlCellTypeVisible).Copy wsA.Range("A1")
        .AutoFilterMode = False
    End With
    
End Sub

Sub UpdateMEWSEntries()
Dim wsA As Worksheet:   Set wsA = Sheets("Results")
Dim wsD As Worksheet:   Set wsD = Sheets("MS EWS download")

'go to the end of Results
    wsA.UsedRange.SpecialCells (xlCellTypeLastCell)

'Use the autofilter to grab all audit entries from data sheet
    With wsD
        .AutoFilterMode = False
        .Range("A:A").AutoFilter
        .Range("A:A").AutoFilter Field:=1, Criteria1:="yes"
        .UsedRange.SpecialCells(xlCellTypeVisible).Copy wsA.Range("A1")
        .AutoFilterMode = False
    End With
    
End Sub
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Hia
Welcome to MrExcel
Is this what you're after
Code:
Sub UpdateMEWSEntries()
Dim wsA As Worksheet:   Set wsA = Sheets("Results")
Dim wsD As Worksheet:   Set wsD = Sheets("MS EWS download")
Dim NxtRw As Long

'go to the end of Results
    NxtRw = wsA.Range("A" & Rows.Count).End(xlUp).Offset(1).Row

'Use the autofilter to grab all audit entries from data sheet
    With wsD
        .AutoFilterMode = False
        .Range("A:A").AutoFilter
        .Range("A:A").AutoFilter Field:=1, Criteria1:="yes"
        .UsedRange.SpecialCells(xlCellTypeVisible).Copy wsA.Range("A" & NxtRw)
        .AutoFilterMode = False
    End With
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,636
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top