Copy paste from one sheet to another problem

adnan1975

New Member
Joined
Aug 24, 2017
Messages
38
I have problem with the following code. I am trying to copy data from one sheet "rp" and paste it into "peim" provided the if conditions is met. The code runs fine except it copy paste over the same cells in the destination sheet.
So there are about 6 entries in the source sheet and i want all 6 entries to be pasted in destination sheet in rows. But my code just over writes the same row with all 6 entries and only show the last entry. I dont know who to make it work so that it copy and paste paste each entry in the next available row.

Code:
Sub final_Report()




    Dim rng As Range
    Dim PEIM_Report As Worksheet
    Dim Report As Worksheet
    Dim eDate As Date
    Dim sDate As Date
    Dim Sformula As String
    


Set peim = ThisWorkbook.Sheets("PEIM_Report")
Set rp = ThisWorkbook.Sheets("Report")


lr = rp.Cells(Rows.Count, 1).End(xlUp).Row
lrp = peim.Cells(Rows.Count, 1).End(xlUp).Row


       
    For x = 6 To lr
       If rp.Cells(x, 14).Value = "Yes" Then
      rp.Range("A" & x, "F" & x).Copy
    peim.Cells(lrp + 1, 1).PasteSpecial xlPasteValues
        Application.CutCopyMode = False
        End If
    Next x


End Sub

Thanks in advance for any help.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Add this line as shown
Code:
peim.Cells(lrp + 1, 1).PasteSpecial xlPasteValues
[COLOR=#0000ff]lrp=lrp+1[/COLOR]
Application.CutCopyMode = False
 
Upvote 0

Forum statistics

Threads
1,215,883
Messages
6,127,546
Members
449,385
Latest member
KMGLarson

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