Searching

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I use a macro that searches a spresdsheet for cells containing certain text.
I use the find like this:

..Cells.Find("GBP", LookIn:=xlValues)

the "GBP" is supposed to be unique in the spreadsheet in the sens that on
that worksheet only one cell has exactly that text. However other cells have
text like:
"Float GBP" or GBP(index)" and this causes problems becuase then the find
function does not always find the correct cell. I know it is possible to
change in the spreadsheet but I keep getting new info and it is not possible
to change it all manually. Is there any way of doing this, I mean search for
a unique cell content? I would be most grateful for any assistance. Thank you
very much!
 
Hi Victor,

Try

'=============>>
Public Sub Tester()
Dim rng As Range
Const sStr As String = "GBP"

Set rng = ActiveSheet.UsedRange

Set rng = Cells.Find(What:=sStr, _
After:=rng(1), _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not rng Is Nothing Then
rng.Select
Else
MsgBox "Unable to find """ & sStr & """"
End If

End Sub
'<<=============
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top