abmoraes86
26-01-2015 02:01:15
Olá. Vi um tutorial de como fazer uma agenda telefonica em vba, porém, quando eu digito no campo para buscar o nome de algum contato, ela apenas me retorna o primeiro resultado, não sendo possível retornar outros resultados com o mesmo nome. Como resolvo isso?
Desculpe pela explicação pobre, mas ainda sou leigo no assunto.
Segue o código:
Private Sub cmdBusca_Click()
If txtLocalizar.Text = "" Then
MsgBox "Você deve digitar o nome do contato a ser localizado!", vbInformation, "Agenda"
Exit Sub
Else
txtLocalizar = UCase(txtLocalizar)
Plan1.Range("A2").Select
End If
Do
If IsNumeric(ActiveCell) Then
ActiveCell.Offset(0, 1).Select
If ActiveCell.Value = txtLocalizar.Value Then
Exit Do
End If
ActiveCell.Offset(1, -1).Select
If IsEmpty(ActiveCell) Then
MsgBox "Contato não localizado", vbInformation, "Agenda"
Exit Do
Exit Sub
End If
Else
Exit Do
End If
Loop Until ActiveCell.Text = txtLocalizar.Text
On Error Resume Next
ActiveCell.Offset(0, -1).Select
CarregarDadosnoFormulário
End Sub
Desculpe pela explicação pobre, mas ainda sou leigo no assunto.
Segue o código:
Private Sub cmdBusca_Click()
If txtLocalizar.Text = "" Then
MsgBox "Você deve digitar o nome do contato a ser localizado!", vbInformation, "Agenda"
Exit Sub
Else
txtLocalizar = UCase(txtLocalizar)
Plan1.Range("A2").Select
End If
Do
If IsNumeric(ActiveCell) Then
ActiveCell.Offset(0, 1).Select
If ActiveCell.Value = txtLocalizar.Value Then
Exit Do
End If
ActiveCell.Offset(1, -1).Select
If IsEmpty(ActiveCell) Then
MsgBox "Contato não localizado", vbInformation, "Agenda"
Exit Do
Exit Sub
End If
Else
Exit Do
End If
Loop Until ActiveCell.Text = txtLocalizar.Text
On Error Resume Next
ActiveCell.Offset(0, -1).Select
CarregarDadosnoFormulário
End Sub