"Build Error" message (Loop without Do)

Asked

Viewed 2,823 times

2

I don’t understand why I ever put Do Until!

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   

                    Linha = Linha + 1

            Loop

            Exit Sub   

        Else   

            MsgBox "Cliente não encontrado!"   

        End If   
    End With   

    Linha1:   

    End If   
End Sub
  • 1

    What is the error message? It would not be better to indent the code?

  • Duplicate, http://answall.com/questions/137590/como-locator-pr%C3%B3ximos-values-of-a-same-customer

1 answer

0


Try:

Do

  ...
  ...

Loop Until Sheets("Dados Clientes").Cells(0, 1) = "" 

In front of the DO don’t put anything.

  • 1

    Be sure to "match" your codes, they are all difficult to analyze without identation! Don’t forget to vote (see the website help)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.