.Find over a range of cells not just a row.

MadeleineB

New Member
Joined
Sep 23, 2008
Messages
18
I'm trying to search for text over a range of cells. My code works for one row but I can't get it to work for a range of cell AP6:HM55<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
<o:p></o:p>
Help please?<o:p></o:p>
<o:p></o:p>
With Worksheets("Buisness")
myDay1row = .Range("9:9").Find(What:="Day 1", After:=.Range("IV9"), LookIn:=xlValues, LookAt:=xlWhole, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Row
End With
<o:p></o:p>
<o:p> </o:p>
Thanks<o:p></o:p>
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Hi, You may find what you want if you look in the VB Help for "FindNext"
Regards Mick
 
Upvote 0
I've look at the VB Help and tryed to put the range up the top like the below but I get a error Run-time eror '1004': Application-defined or object-defined error.

If I take out the After:=.Range("HM55") I then get the error Run-time error '91': Object variable or With block varable not set

My VB knowledge is not good enough to fix it. Can I take away the With statment?

With Worksheets("Buisness").Range("AP6:HM55")
myDay1row = .Find(What:="Day 1", After:=.Range("HM55"), LookIn:=xlValues, LookAt:=xlWhole, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Row
End With<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
 
Last edited:
Upvote 0
Hi Try this , mod the Sheet name and Ranges (The Range is the range to look at) to suit.
I don't know what you want to do with the results , so there in a Msgbox !!
Code:
Dim c As Range, fstaddress, oDay As String
With Worksheets("sheet83").Range("a1:h500")
    Set c = .Find("Day 1", LookIn:=xlValues)
    If Not c Is Nothing Then
        fstaddress = c.Address
        Do
        Set c = .FindNext(c)
        oDay = oDay & c.Address & Chr(10)
        Loop While Not c Is Nothing And c.Address <> fstaddress
    End If
End With
MsgBox "Text ""Day 1"" found in Cells :- " & Chr(10) & oDay
Regards Mick
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,583
Messages
6,125,665
Members
449,247
Latest member
wingedshoes

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