Finding specific text and selecting

chadski778

Active Member
Joined
Mar 14, 2010
Messages
297
I would like a macro to search my worksheet and find the cell containing "Actual%" and selecting the row that it is on as well as all rows of data below it. "Actual%" only appears once in my worksheet

Thanks
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Perhaps

Code:
Sub Slct()
Dim LR As Long, Found As Range
LR = Cells.Find("*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
Set Found = Cells.Find(what:="Actual%", LookIn:=xlValues, lookat:=xlWhole)
If Not Found Is Nothing Then Rows(Found.Row & ":" & LR).Select
End Sub
 
Upvote 0
Try

Code:
Sub Slct()
Dim LR As Long, Found As Range
LR = Cells.Find("*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
Set Found = Cells.Find(what:="Actual%", LookIn:=xlValues, lookat:=xlWhole)
If Not Found Is Nothing Then Range(Cells(Found.Row, 6), Cells(LR, 9)).Select
End Sub

Also, try posting your entire question in your initial post.
 
Upvote 0
Sorry I thought the last request would suffice but I couldn't paste the selection so I thought I'd better make it smaller

It works fine now

Thank you
 
Upvote 0
That was very useful thanks. Please could I have a modification on that macro so that the range of cells selected is limited up to the first empty row below ("Value%) rather then the last occupied row on the spreadsheet

Thanks
 
Upvote 0
Try

Code:
Sub Slct()
Dim LR As Long, Found As Range
Set Found = Cells.Find(what:="Actual%", LookIn:=xlValues, lookat:=xlWhole)
If Found Is Nothing Then Exit Sub
LR = Found.End(xlDown).Row
Range(Cells(Found.Row, 6), Cells(LR, 9)).Select
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,291
Members
452,902
Latest member
Knuddeluff

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