It's a simple question, but I researched and could not find something specific to my case. The code below corresponds to searching for data in a table, but when there is more than 1 corresponding value, it replaces the last found value. What I would like is for it to add a line as in the example below:
** The example has no relation to the code
Table
AAA 111 222 333
AAA 111 555 777
Search: AAA
Current result:
AAA 111 555 777 (replaced by AAA 222 333)
What I would like:
AAA 111 222 333
AAA 111 555 777
Private Sub Pesquisar_Click()
Dim nApol As String
Dim nApolBanco As String
Dim nlin As Long
Dim Linha As Range
Application.ScreenUpdating = False
If Len(Me.TextBox1.Value) > 3 Then
nApol = TextBox1.Value + TextBox2.Value + TextBox3.Value
For nlin = 2 To Sheets("Banco de Dados").Cells(Rows.Count, "B").End(xlUp).Row
nApolBanco = Cells(nlin, "B")
If UCase(nApolBanco) Like nApol Then
MsgBox ("Found")
ListBox1.ColumnCount = 14
ListBox1.RowSource = Range(Cells(nlin, "A"), Cells(nlin, "T")).Address
End If
Next
Else
MsgBox ("Não encontrado")
End If
End Sub