ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Search String within String (https://www.excelbanter.com/excel-programming/353358-search-string-within-string.html)

gti_jobert[_16_]

Search String within String
 

Hi all,

I have a long list of part numbers in the format - '01821-00406'. I was
wondering if it is possible to have a text box on a form where the user
could enter a few digits of a part number then return a list of part
numbers containing the search string?

Thanks for any help!!

Joe @ work


--
gti_jobert
------------------------------------------------------------------------
gti_jobert's Profile: http://www.excelforum.com/member.php...o&userid=30634
View this thread: http://www.excelforum.com/showthread...hreadid=512651


gti_jobert[_17_]

Search String within String
 

Would this work, have wrote the code but cant test it yet as form is not
built;


Code:
--------------------

i = 1
Do
If InStr(1, Cells(i, 1).Value, txtSearchString.Text) = True Then
'display numbers in datagrid
End If
i = i + 1
Loop Until Cells(i, 1).Value = ""

--------------------


--
gti_jobert
------------------------------------------------------------------------
gti_jobert's Profile: http://www.excelforum.com/member.php...o&userid=30634
View this thread: http://www.excelforum.com/showthread...hreadid=512651


Toppers

Search String within String
 

Try something like this which will place list in a combobox:

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Part = TextBox1.Value
ComboBox1.Clear
For Each cell In Worksheets("Sheet1").Range("A1:A100") <=== change
If cell Like Part & "*" Then
ComboBox1.AddItem cell.Value
End If
Next cell
End Sub

"gti_jobert" wrote:


Hi all,

I have a long list of part numbers in the format - '01821-00406'. I was
wondering if it is possible to have a text box on a form where the user
could enter a few digits of a part number then return a list of part
numbers containing the search string?

Thanks for any help!!

Joe @ work


--
gti_jobert
------------------------------------------------------------------------
gti_jobert's Profile: http://www.excelforum.com/member.php...o&userid=30634
View this thread: http://www.excelforum.com/showthread...hreadid=512651



gti_jobert[_18_]

Search String within String
 

I've done it now, but for all those that want to know....this is how i
can be achieved;


Code
-------------------

Private Sub cmsSearch_Click()

Dim i%

ActiveWorkbook.Sheets("RelationalData").Activate
Range("A1").Select

i = 3
Do
If InStr(1, Cells(i, 7).Value, txtSearch.Text, vbTextCompare) < 0 Then
With lstResult
.AddItem Cells(i, 7).Value
End With
End If
i = i + 1
Loop Until Cells(i, 7).Value = ""

End Sub

-------------------

--
gti_jober
-----------------------------------------------------------------------
gti_jobert's Profile: http://www.excelforum.com/member.php...fo&userid=3063
View this thread: http://www.excelforum.com/showthread.php?threadid=51265



All times are GMT +1. The time now is 11:02 AM.

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