Notifications
Clear all
2024 - VBA & Macros
2
Posts
1
Usuários
0
Reactions
886
Visualizações
Topic starter
Galera, acho que deve ser facil porem sou iniciante em VBA e tenho uma duvida.
criei uma userform com 10 botoes optionbuton e criei outro botao normal para ao clicar nele, mudar o optionbutton que esta selecionado.
tentei criar uma variavel "mudar", para aumentar em 1 toda vez que clicasse o botão, porem nao deu muito certo.
Alguem sabe como faço?
Codigo no Modulo 1 para abrir o userform:
Sub ShowForm() [b]mudar[/b] = 1 frm_Passagens("opt_1").Value = True frm_Passagens("txt_RS").Value = 1 frm_Passagens("lst_Companhia").Value = "Gol" frm_Passagens.Show End Sub
Código dentro do userform:
Private Sub btn_Proximo_Click() If [b]mudar[/b] = 9 Then [b]mudar[/b] = 1 Else [b]mudar[/b] = [b]mudar[/b] + 1 frm_Passagens("opt_" & [b]mudar[/b]).Value = True If opt_[b]mudar[/b] = True Then frm_Passagens("txt_RS").Value = [b]mudar[/b] Else End If End If End Sub Private Sub btn_Sair_Click() Unload Me End Sub Private Sub opt_1_Click() If opt_1 = True Then frm_Passagens("txt_RS").Value = "1" mudar = 1 Else End If End Sub Private Sub opt_2_Click() If opt_2 = True Then frm_Passagens("txt_RS").Value = "2" mudar = 2 Else End If End Sub Private Sub opt_3_Click() If opt_3 = True Then frm_Passagens("txt_RS").Value = "3" mudar = 3 Else End If End Sub Private Sub opt_4_Click() If opt_4 = True Then frm_Passagens("txt_RS").Value = "4" mudar = 4 Else End If End Sub Private Sub opt_5_Click() If opt_5 = True Then frm_Passagens("txt_RS").Value = "5" mudar = 5 Else End If End Sub Private Sub opt_6_Click() If opt_6 = True Then frm_Passagens("txt_RS").Value = "6" mudar = 6 Else End If End Sub Private Sub opt_7_Click() If opt_7 = True Then frm_Passagens("txt_RS").Value = "7" mudar = 7 Else End If End Sub Private Sub opt_8_Click() If opt_8 = True Then frm_Passagens("txt_RS").Value = "8" mudar = 8 Else End If End Sub Private Sub opt_9_Click() If opt_9 = True Then frm_Passagens("txt_RS").Value = "9" mudar = 9 Else End If End Sub Private Sub opt_Novo_AfterUpdate() If opt_Novo = True Then frm_Passagens("txt_RS").Value = "" Else End If End Sub
Ficaria muito agradecido se conseguissem me ajudar.
Postado : 01/09/2015 1:14 pm
Topic starter
Coloquei o arquivo em anexo para facilitar a visualização.
obs: pode ser de qualquer forma que eu consiga apertar o botão e mudar a optbox que está selecionada, não precisa ser como eu tentei fazer.
Muito Obrigado,
Renato
Postado : 02/09/2015 12:17 pm