2
I’m trying to add an entire line to a listbox, based on the result of a search .Find
, the idea is to find the value that matches the searched term it adds each line that contains this value in the listbox.
I tried some ways that didn’t work out.
Private Sub CommandButton2_Click()
Dim a As Range
Dim pesquisa As Range
Dim valor As String
Dim resultado As Range
Dim resultadoAnterior As Range
Dim intervalo As Range
Dim linha As Range
Set intervalo = Range("B1:B100")
With frmPesquisa
valor = Me.TextBox1.Value + "*"
Set resultado = intervalo.Find(valor, LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByColumns)
Do
Set resultadoAnterior = resultado
Set resultado = intervalo.Find(valor, After:=resultadoAnterior, LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByColumns)
linha = resultadoAnterior.EntireRow
ListBox1.AddItem (linha)
Loop Until resultado.Row < resultadoAnterior.Row
End With
End Sub