• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Simple macro to copy data with criteria

Dannis

New Member
Hi all im trying to create a macro that will copy data from source data to a new sheet when the data in column B=A, this is what i have come up with but gives errors ; where am i going wrong ?

THX


Sub copytoworksheet()

finalrow = Cells(Rows.Count, 2).End(xlUp).Row

For i = 1 To finalrow

If Cells(i, 2) = "A" Then

lastRow = Sheets("New").Range("A" & Rows.Count).End(xlUp).Row + 1

EntireRow.Copy Destination:=Sheets("New").Range("A" & lastRow)

End If

Next i

End Sub
 
Not sure this is what you want but

change:

Code:
EntireRow.Copy Destination:=Sheets("New").Range("A" & lastRow)


to:

Rows(i).Copy Destination:=Sheets("New").Range("A" & lastrow)
 
A extension to this....if I have to copy data to different file. Or pull data (filtered) from one file to another file. Or both. I need to move data, which is filtered based on certain criteria, from one file to a different file, which will use that data for further analysis.


Please guide me.
 
Back
Top