TekillaSunrize
New Member
- Joined
- Sep 24, 2021
- Messages
- 12
- Office Version
- 2019
- 2016
- Platform
- Windows
Hello,
I have the following macro:
The problem is that when i search for the number using textbox1 and i press the CommandButton1 it brings me only one result and not all the results associated with my search keyword, like in the example below:
Appreciate if anyone could help me with this,
Thanks!
I have the following macro:
VBA Code:
Private Sub CommandButton1_Click()
Dim master_ticket_id As String
master_ticket_id = Trim(TextBox1.Text)
lastrow = ActiveWorkbook.Sheets(1).Cells(Rows.Count, 11).End(xlUp).Row
For i = 2 To lastrow
On Error Resume Next
If ActiveWorkbook.Sheets(1).Cells(i, 11).Value = master_ticket_id Then
ListBox1.ColumnCount = 5
ListBox1.ColumnHeads = True
ListBox1.ColumnWidths = "110;30;30;20"
ListBox1.AddItem
ListBox1.List(0, 0) = (ActiveWorkbook.Sheets(1).Cells(i, 8).Value)
ListBox1.List(0, 1) = (ActiveWorkbook.Sheets(1).Cells(i, 12).Value)
ListBox1.List(0, 2) = (ActiveWorkbook.Sheets(1).Cells(i, 10).Value)
ListBox1.List(0, 3) = (ActiveWorkbook.Sheets(1).Cells(i, 15).Value)
End If
Next
End Sub
The problem is that when i search for the number using textbox1 and i press the CommandButton1 it brings me only one result and not all the results associated with my search keyword, like in the example below:
Appreciate if anyone could help me with this,
Thanks!