Macro to copy next row

Richyog

New Member
Joined
Sep 6, 2011
Messages
15
Hi,
I just want to copy the next two row after the specific word.

Suppose there is a word "dynamic data" and after this word i want to copy the next two rows of that sheet to the sheet2.

Summarizing:-
1.To find a specific word by MACRO
2.Copy next two rows after this word.
3.PAste it to the new sheet
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Try like this

Code:
Sub test3()
Dim Found As Range
With Sheets("Sheet1")
    Set Found = .Cells.Find(what:="dynamic data", kookin:=xlValue, lookat:=xlWhole)
    If Not Found Is Nothing Then Found.Offset(1).Resize(2).EntireRow.Copy Destination:=Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1)
End With
End Sub
 
Upvote 0
Hi Peter,

Thanks for the quick reply but i wanted that next two or three or may be 4 rows after a word can be copied.
This macro is giving an error i.e."Name argument not found"
What is this error.Why it is showing there.What mistake I had done so that i am getting this error
 
Upvote 0
Sorry, I had a couple of typos. Try

Code:
Sub test3()
Dim Found As Range, n As Long
n = Application.InputBox("How many rows", Type:=1)
With Sheets("Sheet1")
    Set Found = .Cells.Find(what:="dynamic data", LookIn:=xlValues, lookat:=xlWhole)
    If Not Found Is Nothing Then Found.Offset(1).Resize(n).EntireRow.Copy Destination:=Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1)
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,946
Latest member
JoseDavid

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