ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Searching a String (https://www.excelbanter.com/excel-programming/294205-searching-string.html)

dcstech

Searching a String
 
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



Bob Phillips[_6_]

Searching a String
 
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)

"dcstech" wrote in message
...
I have a list of ID numbers. They are as follows:

bttest123
bttest456
cttest123
bttest456

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.





dcstech

Searching a String
 
Thanks for the help


All times are GMT +1. The time now is 07:28 PM.

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