4
It’s a simple question, but I did some research, and I couldn’t find anything 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 him to add a line as the example below:
**The example is unrelated to the code
Table
AAA 111 222 333
AAA 111 555 777
Look for: AAA
Result currently:
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