Filtering by variable criteria, then copy-paste the data

amne112

New Member
Joined
Sep 27, 2019
Messages
1
Hi!

I need to Filter An array of data by a criteria(emails), then the filtered results has to be pasted in other sheet, at a specific row(the row corresponding to each email address), but if there are two or many rows that has to be pasted, excel has to add the additional rows in the sheet. I will leave here the macro recorder code I have made for two of the email Addresses from the list.

Code:
Sub Find_email_copy_paste()
'
' Find_email_copy_paste Macro
'

'
    Sheets("cheat").Select
    Selection.Copy
    Sheets("EMP_Log").Select
    ActiveSheet.Range("$A$1:$G$8458").AutoFilter Field:=7, Criteria1:= _
        "First@email.com"
    Sheets("CR_Matrix").Select
    Columns("N:N").Select
    Selection.Find(What:="First@email.com", After:=ActiveCell, _
        LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, _
        SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Activate
    Range("N9").Select
    Sheets("EMP_Log").Select
    Range("D426").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("CR_Matrix").Select
    Range("P9").Select
    ActiveSheet.Paste
    Sheets("cheat").Select
    Range("A3").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("EMP_Log").Select
    ActiveSheet.Range("$A$1:$G$8458").AutoFilter Field:=7, Criteria1:= _
        "Second@email.com"
    Sheets("CR_Matrix").Select
    Columns("N:N").Select
    Selection.Find(What:="Second@email.com", After:=ActiveCell, LookIn:= _
        xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
        xlNext, MatchCase:=False, SearchFormat:=False).Activate
    Range("P13").Select
    Sheets("EMP_Log").Select
    Range("D8081").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("CR_Matrix").Select
    ActiveSheet.Paste
    Range("P14").Select
    Application.CutCopyMode = False
    Selection.EntireRow.Insert
    Sheets("EMP_Log").Select
    Range("D8173").Select
    Selection.Copy
    Sheets("CR_Matrix").Select
    ActiveSheet.Paste
End Sub

Thanks in advance!
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,223,885
Messages
6,175,187
Members
452,616
Latest member
intern444

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