This document contains code for an auto-search function in Visual Basic. When a key is pressed in a text box, it calls the Pesquisa_Auto subroutine. This subroutine searches rows in a Planilha3 spreadsheet between 5 and 1000 for matches to the search term in the first column, and adds any matching rows to a list box with 4 columns of data from the spreadsheet. It clears the list box first before adding any new matches.
This document contains code for an auto-search function in Visual Basic. When a key is pressed in a text box, it calls the Pesquisa_Auto subroutine. This subroutine searches rows in a Planilha3 spreadsheet between 5 and 1000 for matches to the search term in the first column, and adds any matching rows to a list box with 4 columns of data from the spreadsheet. It clears the list box first before adding any new matches.
This document contains code for an auto-search function in Visual Basic. When a key is pressed in a text box, it calls the Pesquisa_Auto subroutine. This subroutine searches rows in a Planilha3 spreadsheet between 5 and 1000 for matches to the search term in the first column, and adds any matching rows to a list box with 4 columns of data from the spreadsheet. It clears the list box first before adding any new matches.
Private Sub TextBox1_KeyUp(ByVal KeyCode As MSForms.
ReturnInteger, ByVal Shift As
Integer) Call Pesquisa_Auto End Sub Private Sub Pesquisa_Auto() Dim Lin As Integer, LinBox As Integer Dim Busca As Integer, Contador As Integer Lin = 5 LinBox = 1 Contador = 0
ListBox1.Clear
Do While Lin < 1000
Busca = InStr(Planilha3(Linha, 1), Pesquisa) If Busca > 0 Then With ListBox1 .AddItem .List(LinBox, 0) = Planilha3(Lin, 1) .List(LinBox, 1) = Planilha3(Lin, 2) .List(LinBox, 2) = Planilha3(Lin, 3) .List(LinBox, 3) = Planilha3(Lin, 4) End With LinBox = LinBox + 1 Contador = Contador + 1 End If Lin = Lin + 1 Loop