- 27 Set 2016 às 15:24
#15682
A rotina de gravar dados abaixo
Private Sub CmdCadastrar_Click()
'Validação de preenchimento obrigatório de texto, OptionButton e CheckBox
'TextBox
If TxtCodigo = "" Then
MsgBox "Preenchimento Obrigatório", vbExclamation, "Preencha do Codigo da Empresa"
TxtCodigo.SetFocus
Exit Sub
End If
If Not IsDate(TextBox1) Then
MsgBox "Preenchimento Obrigatório", vbExclamation, "Preencha a Data Corretamente"
TextBox1.SetFocus
Exit Sub
End If
If TextBox2 = "00:00" And TextBox3 = "00:00" Then
MsgBox "Preenchimento Obrigatório", vbExclamation, "Preencha a Hora de Início e Fim da Atividade"
TextBox3.SetFocus
Exit Sub
End If
'OptionButton atividade
If OptionButton1.Value = False And OptionButton2.Value = False And OptionButton3.Value = False And OptionButton4.Value = False And OptionButton5.Value = False And OptionButton6.Value = False And OptionButton7.Value = False And OptionButton8.Value = False And OptionButton9.Value = False And OptionButton10.Value = False And OptionButton11.Value = False And OptionButton12.Value = False Then
MsgBox "Campo Atividade!", vbExclamation, "Preenchimento Obrigatório!"
Exit Sub
End If
'OptionButton Ano Trabalhado
If OptionButton18.Value = True And ComboBox1 = "" Then
MsgBox "Selecione o Motivo do Reprocessamento!", vbExclamation, "Preenchimento Obrigatório!"
Exit Sub
End If
' Posiciona o Curso na Primeira Celula Vazia da Coluna "A"
Sheets("Cadastro").Select
Range("A65536").End(xlUp).Offset(1, 0).Select
If Not IsNumeric(ActiveCell.Offset(-1, 0)) Then
ActiveCell = 1
Else
ActiveCell = ActiveCell.Offset(-1, 0) + 1
End If
'Gravar dados do formulário - (grava dados de caixa de Texto
'active.Cell.Offset(0, 1) <-- grava na linha vazia coluna 1
ActiveCell.Offset(0, 1).Value = DateValue(TextBox1.Text) 'data
ActiveCell.Offset(0, 2) = CmbColaborador
ActiveCell.Offset(0, 3) = VblCoordenador
ActiveCell.Offset(0, 4) = TxtCodigo
ActiveCell.Offset(0, 5) = Empresa
ActiveCell.Offset(0, 8) = ComboBox1
ActiveCell.Offset(0, 11) = TextBox2 'hora Inicial
ActiveCell.Offset(0, 12) = TextBox3 'hora Final
'informações checkbox meses trabalhados
ActiveCell.Offset(0, 19) = CheckBox1 'Jan
ActiveCell.Offset(0, 20) = CheckBox2 'Fev
ActiveCell.Offset(0, 21) = CheckBox3 'Mar
ActiveCell.Offset(0, 22) = CheckBox4 'Abr
ActiveCell.Offset(0, 23) = CheckBox5 'Mai
ActiveCell.Offset(0, 24) = CheckBox6 'Jun
ActiveCell.Offset(0, 25) = CheckBox7 'Jul
ActiveCell.Offset(0, 26) = CheckBox8 'Ago
ActiveCell.Offset(0, 27) = CheckBox9 'Set
ActiveCell.Offset(0, 28) = CheckBox10 'Out
ActiveCell.Offset(0, 29) = CheckBox11 'Nov
ActiveCell.Offset(0, 30) = CheckBox12 'Dez
'Função If para gravar dados de Botao de Opção Frame Atividade
'Caso a Marcação seja Verdadeira ele grava o que está escrito no value....
If OptionButton1.Value = True Then
ActiveCell.Offset(0, 6).Value = "Recebimentos"
ElseIf OptionButton2.Value = True Then
ActiveCell.Offset(0, 6).Value = "Importação XML"
ElseIf OptionButton3.Value = True Then
ActiveCell.Offset(0, 6).Value = "Conv. N.F. Tom./Prest."
ElseIf OptionButton4.Value = True Then
ActiveCell.Offset(0, 6).Value = "Classif. N.F."
ElseIf OptionButton5.Value = True Then
ActiveCell.Offset(0, 6).Value = "Soma/Conferência"
ElseIf OptionButton6.Value = True Then
ActiveCell.Offset(0, 6).Value = "Correção Arquivos"
ElseIf OptionButton7.Value = True Then
ActiveCell.Offset(0, 6).Value = "Emissão de Guias"
ElseIf OptionButton8.Value = True Then
ActiveCell.Offset(0, 6).Value = "Emiss. Guias Imp. Retidos"
ElseIf OptionButton9.Value = True Then
ActiveCell.Offset(0, 6).Value = "Envio de Guias"
ElseIf OptionButton10.Value = True Then
ActiveCell.Offset(0, 6).Value = "Recalc Guias"
ElseIf OptionButton11.Value = True Then
ActiveCell.Offset(0, 6).Value = "Ativ. Adm./Consultoria"
ElseIf OptionButton12.Value = True Then
ActiveCell.Offset(0, 6).Value = "Livros"
Else
ActiveCell.Offset(0, 6) = ""
End If
'Função If para gravar dados de Botao de Opção do Frame Ano Trabalhado
If OptionButton18.Value = True Then
ActiveCell.Offset(0, 7).Value = "Sim"
Else
ActiveCell.Offset(0, 7) = ""
End If
'Função If para gravar dados de Botao de Opção do Obrigações Acessórias
If OptionButton16.Value = True Then
ActiveCell.Offset(0, 9) = "GIA"
ElseIf OptionButton13.Value = True Then
ActiveCell.Offset(0, 9) = "SPEED Fiscal"
ElseIf OptionButton17.Value = True Then
ActiveCell.Offset(0, 9) = "EFD Contribuições"
ElseIf OptionButton15.Value = True Then
ActiveCell.Offset(0, 9) = "SEDIF"
ElseIf OptionButton14.Value = True Then
ActiveCell.Offset(0, 9) = "REDF"
Else
ActiveCell.Offseift(0, 9) = ""
End If
TextBox4 = Format(TimeValue(TextBox3) - TimeValue(TextBox2), "hh:nn:ss")
End Sub
esta rotina esta funcionando belezinha e na planilha para completar o relatório tem função somase para somar as horas cadastradas por atividade e data e uma função se para extrair a hora de almoço!!!!
a rotina roda normalmente as as funçoes na planilha não!!!!