ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Search column (https://www.excelbanter.com/excel-programming/400679-search-column.html)

Greg B[_11_]

Search column
 
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



Gary''s Student

Search column
 
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

--
Gary''s Student - gsnu2007a


"Greg B" wrote:

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





All times are GMT +1. The time now is 08:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com