Jump to content
Fórum Script Brasil
  • 0

VBA - error '1004'


Felipe Monteiro

Question

Boa noite,
Estou com um problema na hora de preencher uma ListBox no VBA, quando ele começa a executar a função pesquisaCliente ele da um erro no Sheets("Pesquisa").Range("A2:K1000000").Clear, já testei em apagar essa linha e ele continua com o erro na linha abaixo.

Sub pesquisaCliente()
    Dim n As Long
    n = 1
   
    Sheets("Pesquisa").Range("A2:K1000000").Clear
    Sheets("RegServ").Select
    Sheets("RegServ").Range("D4").Select
   
    Do While ActiveCell <> ""
        If InStr(1, UCase(ActiveCell), UCase(txt_cpf)) > 0 Then
            Sheets("Pesquisa").Range("B" & n).Offset(1, -1).Value = ActiveCell.Offset(0, -1)
            Sheets("Pesquisa").Range("B" & n).Offset(1, 0).Value = ActiveCell.Offset(0, 0)
            Sheets("Pesquisa").Range("B" & n).Offset(1, 1).Value = ActiveCell.Offset(0, 1)
            Sheets("Pesquisa").Range("B" & n).Offset(1, 2).Value = ActiveCell.Offset(0, 2)
            Sheets("Pesquisa").Range("B" & n).Offset(1, 3).Value = ActiveCell.Offset(0, 3)
            Sheets("Pesquisa").Range("B" & n).Offset(1, 4).Value = ActiveCell.Offset(0, 4)
            Sheets("Pesquisa").Range("B" & n).Offset(1, 5).Value = ActiveCell.Offset(0, 5)
            Sheets("Clientes").Range("B" & n).Offset(1, 6).Value = ActiveCell.Offset(0, 6)
            Sheets("Pesquisa").Range("B" & n).Offset(1, 7).Value = ActiveCell.Offset(0, 7)
            Sheets("Pesquisa").Range("B" & n).Offset(1, 8).Value = ActiveCell.Row
            n = n + 1
        End If
           ActiveCell.Offset(1, 0).Select
    Loop
    If n > 1 Then
        ListBox1.RowSource = "Pesquisa!A2:I" & n
        Sheets("Menu").Select
    Else
        ListBox1.RowSource = ""
        MsgBox "Nenhum registro encontrado", vbInformation, "Aviso"
        Sheets("Menu").Select
    End If

Alguém consegue me ajudar?

Obs: Sou novato no VBA e no forum...

Esse código peguei de um projeto que achei na internet....

https://drive.google.com/open?id=0Bxj25TpncBH2MjBFWE9sYVZKTkk&authuser=0

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...