Searching a String

D

dcstech

I have a list of ID numbers. They are as follows

bttest12
bttest45
cttest12
bttest45

Ok in VBA say that i wanted to search this row of strings using a short segment of the strings

Inputbox1="ct

I would like to return the values that contain the letters "ct" to a listbox

Thanks for any help
 
B

Bob Phillips

Try this

With Worksheets("Sheet1")
On Error Resume Next
Set oCell = .Range("A1:A50").Find(what:="ct", lookat:=xlPart)
If Not oCell Is Nothing Then
sFirst = oCell.Address
Do
.listboxes("List Box 1").additem oCell.Value
Loop While Not oCell Is Nothing And oCell.Address <> sFirst
End If
End

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Top