1
If you could just help me out with this one, and I think you’ll be good for someone else, too. I am trying to make sure that by clicking search the Textbox are filled with customer data, and clicking again on the Search button the Textbox is loaded with the data of the next record of the same client. That is, it goes from registration to registration of the same code.
I’m having a hard time on the Loop.
Private Sub cmdPequisar_Click()
'Verificar se foi digitado um nome na primeira caixa de texto
If txtCPF.Text = "" Then
MsgBox "Digite o CPF de um cliente"
txtCPF.SetFocus
GoTo Linha1
End If
With Worksheets("Dados Clientes").Range("A:A")
Set c = .Find(txtCPF.Value, LookIn:=xlValues, LookAt:=xlPart)
Do Until Sheets("Dados Clientes").Cells(0, 1) = ""
If Sheets("Dados Clientes").Cells(0, 1) = txtCPF Then
If Not c Is Nothing Then
c.Activate
txtCPF.Value = c.Value
txtNome.Value = c.Offset(0, 1).Value
txtEndereco.Value = c.Offset(0, 2).Value
cboEstado.Value = c.Offset(0, 3).Value
cboCidade.Value = c.Offset(0, 4).Value
txtTelefone.Value = c.Offset(0, 5).Value
txtEmail.Value = c.Offset(0, 6).Value
txtNascimento.Value = c.Offset(0, 7).Value
Exit Sub
Linha = Linha + 1
Loop
Else
MsgBox "Cliente não encontrado!"
End If
End With
Linha1:
End If
End Sub
Thank you very much Guilherme Lima, I am very new not noticed when I copied the code.
– ludehenrique2cia