Hi...
When the form is opened it load the names of a spreadsheet in ComboBox1, then I want to select which name search and command, are usually made all the names, how can I do to stop automatically once clicked the button it alone do the research, for all names that are in ComboBox1.
Private Sub UserForm_Initialize()
Dim QuantasLinhas, Cont
QuantasLinhas = Workbooks("Pesquisa1 .xls").Sheets("Dados").Range("A65000").End(xlUp).Row
For Cont = 2 To QuantasLinhas
Me.ComboBox1.AddItem Plan4.Range("A" & Cont)
End Sub
Private Sub PESQUISA_Click()
Dim i As Integer
Dim pes As Variant
Dim WS As Worksheet
Dim rg As Range
For Each WS In ActiveWorkbook.Worksheets
For Each rg In WS.[D1:D80]
If rg = ComboBox1.Value And rg.Offset(, -2) <> "" Then i = i + 1
Next rg
Next WS
txtvalor.Value = i
txtnome.Value = ComboBox1.Value
Me.ListBox1.AddItem Me.txtnome.Value
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 1) = Me.txtvalor.value
End Sub
Att
Osmarls
When the form is opened it load the names of a spreadsheet in ComboBox1, then I want to select which name search and command, are usually made all the names, how can I do to stop automatically once clicked the button it alone do the research, for all names that are in ComboBox1.
Private Sub UserForm_Initialize()
Dim QuantasLinhas, Cont
QuantasLinhas = Workbooks("Pesquisa1 .xls").Sheets("Dados").Range("A65000").End(xlUp).Row
For Cont = 2 To QuantasLinhas
Me.ComboBox1.AddItem Plan4.Range("A" & Cont)
End Sub
Private Sub PESQUISA_Click()
Dim i As Integer
Dim pes As Variant
Dim WS As Worksheet
Dim rg As Range
For Each WS In ActiveWorkbook.Worksheets
For Each rg In WS.[D1:D80]
If rg = ComboBox1.Value And rg.Offset(, -2) <> "" Then i = i + 1
Next rg
Next WS
txtvalor.Value = i
txtnome.Value = ComboBox1.Value
Me.ListBox1.AddItem Me.txtnome.Value
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 1) = Me.txtvalor.value
End Sub
Att
Osmarls