Este fórum está sendo desativado

Depois de 9 anos, este fórum será desativado. Mas calma.... estamos migrando para uma comunidade no DISCORD. Junte-se a nós.

ENTRAR PARA DISCORD

Tópicos relacionados a códigos VBA, gravação de macros, etc.
Por LeoRodrigues
#58761
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
Por babdallas
#58771
Não ficou claro onde está o erro. Se possível, anexe um exemplo para poder depurar.
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]

Estamos migrando para uma comunidade no Discord