Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to search a string from the right ? | Setting up and Configuration of Excel | |||
to search for a string and affect data if it finds the string? | Excel Worksheet Functions | |||
search a string withing a string : find / search hangs | Excel Programming | |||
search for string within a string | Excel Programming | |||
VBA function : How to search a string in another string? | Excel Programming |