Searching a String

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

Guest

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
 
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)
 

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