Search cell for string

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

Guest

Hi! I search column A in an excel file fo ra certain expression. The
expression might look like: G BP730 080708_88571. However the cell I am
trying to locate will only contain part of this string eg G BP730 080708. How
can I do this? Many thanks!
 
Try this:

Sub arneee()
Dim expression As String, v As String
expression = "G BP730 080708_88571"
Set r = Intersect(Range("A:A"), ActiveSheet.UsedRange)
For Each rr In r
v = rr.Value
If InStr(expression, v) > 0 And Len(v) > 0 Then
MsgBox (rr.Address & Chr(10) & rr.Value)
Exit Sub
End If
Next
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