ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Search Listbox Values (https://www.excelbanter.com/excel-programming/395502-search-listbox-values.html)

[email protected]

Search Listbox Values
 
I have a TextBox and a ListBox. My question is Is there a way to
search through the values in the listbox to see if the value entered
in the textbox exists in the Listbox?


Vergel Adriano

Search Listbox Values
 
here's one way:

Sub test()
Dim i As Integer

For i = 0 To ListBox1.ListCount - 1
If TextBox1.Text = ListBox1.List(i) Then
MsgBox TextBox1.Text & " exists in listbox"
Exit Sub
End If
Next i

MsgBox TextBox1.Text & " does not exist in listbox"

End Sub


--
Hope that helps.

Vergel Adriano


" wrote:

I have a TextBox and a ListBox. My question is Is there a way to
search through the values in the listbox to see if the value entered
in the textbox exists in the Listbox?



[email protected]

Search Listbox Values
 
Thats what I was looking for thanks for you help Vergel



All times are GMT +1. The time now is 12:21 AM.

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