Search for text value in range

  • Thread starter Thread starter tig
  • Start date Start date
T

tig

I'm looking for an efficient method to search for a text value. I have
a named range. Let's say range = A7:A14. I want to check cells C7:C14
to find the first cell whose value matches a previously populated
variable. It's possible that none of the cells have that value in it.

It seems that I could use a for all loop but I can't seem to get the
syntax right. I've already got a ton of named ranges. I'm trying to
avoid setting up a bunch more.

Any ideas??

TIA
 
Tig, I don't know if this is what your looking for, but give this code a
shot.

hth , Rick


Sub FindDup()
Dim dupRng As Range, fndRng As Range
Dim x As Long


Set dupRng = Range("A7:A14")
x = 7 '' start row
Do Until IsEmpty(Cells(x, "C").Value)
Set fndRng = dupRng.Find(what:=Cells(x, "C").Value)
If Not fndRng Is Nothing Then
MsgBox ("Duplicate Found at = " & fndRng.Address)
Exit Sub
End If
x = x + 1
Loop

MsgBox ("No Duplicates Found")

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