Search column

  • Thread starter Thread starter Greg B
  • Start date Start date
G

Greg B

I want to be able to type in a surname in a textbox called "surname" and I
want to see if there are any matches to this name on the sheet called
"FULLNAMES" column A.


Thanks

Greg
 
Try this:

Sub colsearch()
Dim s As String
s = Application.InputBox(prompt:="enter name", Type:=2)
listt = ""
With Sheets("FULLNAMES")
n = .Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To n
v = .Cells(i, 1).Value
If Len(v) = Len(Replace(v, s, "")) Then
Else
listt = listt & Chr(10) & i
End If
Next
End With
If listt = "" Then
MsgBox ("not found")
Else
MsgBox ("found in rows:" & listt)
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