VBA Find, Select, and Copy

pinciak

New Member
Joined
Apr 11, 2013
Messages
10
I have all my code but am stuck on this. I have all my points in column A in sheet named "Rates". I need to find the value "Price" and copy the 20 rows below it. Thank you
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Bairn90

New Member
Joined
Jun 2, 2012
Messages
28
I've edited this from a recorded macro. Hopefully it should provide you with roughly what you need

Code:
Sub Macro1()
Cells.Find(What:="price", After:=[A1], LookIn:=xlFormulas, LookAt _
        :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
        False, SearchFormat:=False).Activate


rowcopy = ActiveCell.Row
Rows(rowcopy + 1 & ":" & rowcopy + 21).Copy
End Sub
 
Upvote 0

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
12,979
Office Version
  1. 2013
Platform
  1. Windows
I have all my code but am stuck on this. I have all my points in column A in sheet named "Rates". I need to find the value "Price" and copy the 20 rows below it. Thank you

Hi pinciak, Welcome to MrExcel Message Board and Forum.
If you could explain "points" and the relationship of that to "Price" it would be helpful in constructing the code to copy the twenty rows. It would also be helpful to know what you want to do with the data once copied. Maybe and example if you can work one up.
 
Upvote 0

pinciak

New Member
Joined
Apr 11, 2013
Messages
10
I've edited this from a recorded macro. Hopefully it should provide you with roughly what you need

Code:
Sub Macro1()
Cells.Find(What:="price", After:=[A1], LookIn:=xlFormulas, LookAt _
        :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
        False, SearchFormat:=False).Activate


rowcopy = ActiveCell.Row
Rows(rowcopy + 1 & ":" & rowcopy + 21).Copy
End Sub

This work but it copies the whole row across I only need the values of the A column 20 rows down
 
Upvote 0

Bairn90

New Member
Joined
Jun 2, 2012
Messages
28
This should do it.

Code:
Sub Macro1()
Cells.Find(What:="price", After:=[A1], LookIn:=xlFormulas, LookAt _
        :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
        False, SearchFormat:=False).Activate


rowcopy = ActiveCell.Row
Range("A" & rowcopy + 1 & ":A" & rowcopy + 21).Copy
End Sub
 
Upvote 0

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
12,979
Office Version
  1. 2013
Platform
  1. Windows
This work but it copies the whole row across I only need the values of the A column 20 rows down

This will locate "Price in Col A, then put any data in the 20 cells beneath that on the clipboard for pasting.
Code:
Dim c As Range
Set c = ActiveSheet.Range("A:A").Find("Price", LookIn:=xlValues)
If Not c Is Nothing Then
 C.Offset(1, 0).Resize(20, 1).Copy
End If
 
Upvote 0

Forum statistics

Threads
1,195,669
Messages
6,011,061
Members
441,580
Latest member
BornholmerBjarne

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
Top