Hello,
I am using the following code to populate a listbox on a userform. But now I want to apply it to another listbox, however the column actually has text such as "fire extinguisher 01, Fire extinguisher 02, fire hose 13...." How can I tweak this code to add a wild card so that my query will include any instance of the text "fire" to be included in to the listbox. so that I can get them all regardless of the number. Thank you for the help.
I am using the following code to populate a listbox on a userform. But now I want to apply it to another listbox, however the column actually has text such as "fire extinguisher 01, Fire extinguisher 02, fire hose 13...." How can I tweak this code to add a wild card so that my query will include any instance of the text "fire" to be included in to the listbox. so that I can get them all regardless of the number. Thank you for the help.
VBA Code:
Private Sub FireExtinguisherLabel_Click()
Dim i As Long
Dim Lastrow As Long
ListBox1.SetFocus
'this is from the DEVICE ID column
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To Lastrow
If Cells(i, 8).Value = "" And Cells(i, 2).Value = "Fire" Then ListBox1.AddItem Cells(i, 3).Value & " - " + Cells(i, 4).Value
Next
End Sub