Copy a row from one worksheet to another, based on criteria

Solved/Closed
wy - Oct 27, 2015 at 07:00 PM
vcoolio Posts 1362 Registration date Thursday July 24, 2014 Status Moderator Last seen September 29, 2022 - Feb 20, 2017 at 09:19 PM
Hello,



I'm trying to copy rows from my "master" worksheet to another sheet based on criteria in column A. Can I do this? Please help, thanks!
Related:

12 replies

vcoolio Posts 1362 Registration date Thursday July 24, 2014 Status Moderator Last seen September 29, 2022 250
Oct 28, 2015 at 02:09 AM
Hello Wy,

A code like the following may do the task for you:-

Sub CopyStuff()

Application.ScreenUpdating = False

With ActiveSheet
    .AutoFilterMode = False
    With Range("A1", Range("A" & Rows.Count).End(xlUp))
        .AutoFilter 1, "C"
        On Error Resume Next
        .Offset(1).EntireRow.Copy Sheet2.Range("A" & Rows.Count).End(xlUp).Offset(1)
    End With
    .AutoFilterMode = False
End With

Application.ScreenUpdating = True
Sheet2.Select

End Sub


As I don't know what your criteria is, I've just used the letter "C" for now in the code. Change it to suit yourself.

Following is a link to a test work book I did for another Poster some time ago. I believe it is similar to your situation:-

https://www.dropbox.com/s/b7xmw9eva4ndrpv/Ed.xlsm?dl=0

In the test work book, only those rows with the letter "C" in Column A are transferred to sheet 2. Click on the Copy Data button to see it work.

I hope that this helps.

Cheerio,
vcoolio.
4