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

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Forum statistics

Threads
1,215,036
Messages
6,122,796
Members
449,095
Latest member
m_smith_solihull

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