need help in copy the data from particular row

mebro

New Member
Joined
Jul 12, 2018
Messages
12
Hi

help me with my requirement, I have data in one excel sheet2 and I have created a button with macro, once i execute/run the macro it should copy and paste the data to sheet1 and i wanted to show this data from particular row(let's take A12). I am not sure that i am using right approach or not, Below the code I am using.


Sub pendingcopy()


Dim lastrow As Long, erow As Long
Sheets("Sheet1").Range("A1:D10000").Clear


lastrow = Sheet2.Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastrow
If Sheet2.Cells(i, 6) = "Pending" Then
Sheet2.Cells(i, 3).Copy
erow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Sheet2.Paste Destination:=Worksheets("Sheet1").Cells(erow, 1)

Sheet2.Cells(i, 5).Copy
Sheet2.Paste Destination:=Worksheets("Sheet1").Cells(erow, 2)

Sheet2.Cells(i, 7).Copy
Sheet2.Paste Destination:=Worksheets("Sheet1").Cells(erow, 3)

End If
Next i


Application.CutCopyMode = False
Sheet1.Columns().AutoFit
Range("A10").Select


End Sub
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
This will copy row 12 from sheet2 to the next empty row on sheet1.

Code:
Sheet2.Rows(12).Copy Destination:= Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Offset(1)
 
Upvote 0
thanks for your response, but my requirement is i want to copy the matching data from row 12 in sheet1.
I don't know how to attach the screenshot here. please help me on this.
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,194
Members
453,021
Latest member
pingpong7117

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