Ir para conteúdo
Fórum Script Brasil

Avilez

Membros
  • Total de itens

    2
  • Registro em

  • Última visita

Tudo que Avilez postou

  1. Avilez

    Do While

    desculpa pelo post duplo, mas é que achei a solução e essa pode ser a dúvida de alguém! A minha solução foi trocar o Do While Range("A" & Linha).Value <> "" Linha = Linha + 1 Loop[/codebox] por: [codebox]Do While Worksheets("Comissários").Range("A" & Linha).Value <> "" Linha = Linha + 1 Loop Valeu!
  2. Avilez

    Do While

    Olá galera, Bem, eu comecei os meus estudos sobre VBA a pouquíssimo(ontem, para ser mais exato 12/07) tempo e a minha vontade de aprender é muito grande! Pesquisando sobre os comandos de loop, cheguei ao DO WHILE, a minha idéia é varrer toda uma coluna para que, na hora de cadastrar uma pessoa, não cadastre em cima de uma já existente. Aparentemente o comando DO WHILE está todo correto mas o mesmo não é executado! Alguém pode me ajudar? Grato desde já. :) Option Explicit Public Linha As Integer Private Sub cmdCadComi_Click() If lblNome.Value = "" Then MsgBox "Por favor,preencha todos os campos" End ElseIf (Val(masc1) Or Val(masc2) Or Val(masc3) Or Val(fem1) Or Val(fem2) Or Val(fem3)) > 300 Then MsgBox "Não é possível registrar esta quantidade de Ingressos.", vbOKOnly End Else Do While Range("A" & Linha).Value <> Empty Linha = Linha + 1 Loop Worksheets("Comissários").Activate Linha = Linha + 1 Range("A" & Linha).Value = lblNome Range("B" & Linha).Value = Val(masc1) Range("C" & Linha).Value = Val(fem1) Range("D" & Linha).Value = Val(fem1) + Val(masc1) Range("I" & Linha).Value = Val(masc2) Range("J" & Linha).Value = Val(fem2) Range("K" & Linha).Value = Val(fem2) + Val(masc2) Range("P" & Linha).Value = Val(masc3) Range("Q" & Linha).Value = Val(fem3) Range("R" & Linha).Value = Val(fem3) + Val(masc3) If CheckBox1 = True Then Range("W" & Linha).Value = Fix(((Val(fem1) + Val(masc1) + Val(fem2) + Val(masc2) + Val(fem3) + Val(masc3)) / 10)) End If End If 'Limpar os campos lblNome.Value = "" masc1.Value = "" masc2.Value = "" masc3.Value = "" fem1.Value = "" fem2.Value = "" fem3.Value = "" MsgBox "Cadastro de " & Range("A" & Linha).Value & " realizado com sucesso!", vbOKOnly Worksheets("Menu").Activate End Sub Public Sub Form_KeyPress(KeyAscii As Integer) 'Esse código permite a mudança de quadro de 'texto através do Enter If KeyAscii = 13 Then 'Se o tipo do controle ativo for TextBox If TypeOf Screen.ActiveControl Is TextBox Then 'Simula o pressionamento da tecla TAB SendKeys "{tab}" 'A linha a seguir evita ouvir um bip KeyAscii = 0 End If End If End Sub Private Sub cmdSair_Click() Unload Me End Sub Private Sub fem1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) Dim strValid As String strValid = "0123456789" If InStr(strValid, Chr(KeyAscii)) = 0 Then KeyAscii = 0 End If End Sub Private Sub fem2_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) Dim strValid As String strValid = "0123456789" If InStr(strValid, Chr(KeyAscii)) = 0 Then KeyAscii = 0 End If End Sub Private Sub fem3_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) Dim strValid As String strValid = "0123456789" If InStr(strValid, Chr(KeyAscii)) = 0 Then KeyAscii = 0 End If End Sub Private Sub masc1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) Dim strValid As String strValid = "0123456789" If InStr(strValid, Chr(KeyAscii)) = 0 Then KeyAscii = 0 End If End Sub Private Sub masc2_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) Dim strValid As String strValid = "0123456789" If InStr(strValid, Chr(KeyAscii)) = 0 Then KeyAscii = 0 End If End Sub Private Sub masc3_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) Dim strValid As String strValid = "0123456789" If InStr(strValid, Chr(KeyAscii)) = 0 Then KeyAscii = 0 End If End Sub Private Sub UserForm_Initialize() If Linha = 0 Then Linha = 1 Else End If End Sub [/codebox]
×
×
  • Criar Novo...