Página 1 de 1

Erro tempo de execução 1004

Enviado: 12 Set 2020 às 12:38
por LeoRodrigues
Podem me ajudar?

Senhores, bom dia!

Não sou programador e não tenho experiência em VBA, mas resolvi criar um formulário para ajudar um amigo que tem um consultório. Formulário esse que servirá de preenchimentos de dados durante uma consulta. Pesquisei alguns vídeos e passo a passo na internet e consegui criar o formulário e alguns códigos. Nos 4 primeiros testes o formulário funcionou, mas depois ele começou a dá um erro e grifar de amarelo uma linha específica.

No exemplo acima, escolho um tipo de consulta e clico em inserir (um botão que defini para inserção dos dados na planilha.

Aqui basicamente ele deveria colocar “Novo” se o botão “OptionButton3” estivesse clicado, se não ele colocaria “Retorno”.

Segue o código completo.
Linha negrito abaixo é onde fica grifado de amarelo que depuro o erro.
Private Sub CommandButton1_Click()

linha = Range(“A1”).End(xlDown).Row + 1

If OptionButton3.Value = True Then

Cells(linha, 1) = “Novo”`

Else

Cells(linha, 1) = “Retorno”

End If

Cells(linha, 3) = ComboBox1.Value

Cells(linha, 2) = TextBox2.Value

If OptionButton1.Value = True Then

Cells(linha, 1) = “Masculino”

Else

Cells(linha, 5) = “Femenino”

End If

Cells(linha, 4) = TextBox1.Value

Cells(linha, 5) = TextBox4.Value

Cells(linha, 6) = TextBox5.Value

Cells(linha, 7) = ComboBox2.Value

Cells(linha, 8) = ComboBox3.Value

Cells(linha, 9) = ComboBox4.Value

Cells(linha, 10) = TextBox6.Value

Cells(linha, 11) = TextBox7.Value

Cells(linha, 12) = TextBox8.Value

Cells(linha, 41) = TextBox14.Value

Cells(linha, 42) = TextBox15.Value

Cells(linha, 42) = TextBox15.Value

Cells(linha, 13) = ComboBox5.Value

Cells(linha, 14) = ComboBox6.Value

Cells(linha, 16) = TextBox9.Value

Cells(linha, 15) = ComboBox11.Value

Cells(linha, 15) = ComboBox11.Value

Cells(linha, 18) = ComboBox11.Value

Cells(linha, 19) = ComboBox9.Value

Cells(linha, 21) = ComboBox9.Value

Cells(linha, 22) = ComboBox12.Value

Cells(linha, 23) = ComboBox13.Value

Cells(linha, 24) = ComboBox14.Value

Cells(linha, 20) = ComboBox10.Value

Cells(linha, 25) = ComboBox15.Value

Cells(linha, 26) = ComboBox16.Value

Cells(linha, 27) = ComboBox17.Value

Cells(linha, 28) = ComboBox19.Value

Cells(linha, 29) = ComboBox18.Value

Cells(linha, 31) = ComboBox21.Value

Cells(linha, 32) = TextBox12.Value

Cells(linha, 33) = ComboBox22.Value

Cells(linha, 34) = ComboBox23.Value

Cells(linha, 35) = ComboBox24.Value

Cells(linha, 36) = ComboBox25.Value

Cells(linha, 64) = ComboBox13.Value

Cells(linha, 38) = ComboBox28.Value

Cells(linha, 40) = ComboBox29.Value

Cells(linha, 43) = TextBox16.Value

Cells(linha, 44) = TextBox17.Value

Cells(linha, 46) = TextBox19.Value

Cells(linha, 47) = TextBox20.Value

Cells(linha, 49) = TextBox22.Value

Cells(linha, 45) = TextBox18.Value

Cells(linha, 48) = TextBox21.Value

Cells(linha, 50) = TextBox23.Value

Cells(linha, 51) = TextBox24.Value

Cells(linha, 53) = TextBox26.Value

Cells(linha, 55) = TextBox28.Value

Cells(linha, 57) = TextBox30.Value

Cells(linha, 52) = TextBox25.Value

Cells(linha, 54) = TextBox27.Value

Cells(linha, 56) = TextBox29.Value

Cells(linha, 58) = TextBox31.Value

Cells(linha, 59) = TextBox32.Value

Cells(linha, 60) = TextBox33.Value

Cells(linha, 61) = TextBox34.Value

Cells(linha, 62) = TextBox35.Value

Cells(linha, 63) = TextBox36.Value

End Sub

Re: Erro tempo de execução 1004

Enviado: 13 Set 2020 às 08:21
por babdallas
Não ficou claro onde está o erro. Se possível, anexe um exemplo para poder depurar.