- 30 Dez 2016 às 09:07
#18532
Ola pessoal desculpa a todos que estava tentando me ajudar neste problema eu apertei sem querer no RESOLVIDO mais não está nada resolvido o problema.
Bom dia
Professor GURU,
Sou um principiante em VBA com macro nos meus conhecimentos que são pouco foram todos pela internet no youtube e outros sites.
Estou fazendo uma planilha de contas a pagar aqui na empresa que eu trabalho e estou querendo fazer uma situação automática para quando for digitado nas células exemplo H, I,J, I e L a J -> fica a data de registro que automática do sistema, a célula I -> eu lanço a data de Vencimento a célula J é a data da Confirmação do Pagamento e a célula seguinte que é a L -> é a SITUAÇÃO ou STATOS.
Como seria o resultados deste macro é o seguinte:
Exemplo: " H <= I " Resultado é --> NO PRAZO
" H > I " Resultado é --> VENCIDO
" L > "" " Resultado é --> PAGO
Tudo isso é a traveis de um BOTÃO Adicionar, como este macro do botão.
'PROCEDIMENTO PARA ADICIONAR DADOS AO BD
Public Sub Adicionar()
Dim linha As Integer
Dim conte As Integer
Application.ScreenUpdating = False
linha = 4
conte = 1
If shtPainel.Range("A6") = 1 Then
If shtPainel.Range("Receita") = "" Or shtPainel.Range("Valor") = "" Then
MsgBox "Os campos RECEITA e VALOR São Obrigatórios!", vbCritical, "CAMPOS VAZIOS"
Exit Sub
End If
Else
If shtPainel.Range("CategoriaDespesa") = "" Or shtPainel.Range("Despesa") = "" Or shtPainel.Range("Valor") = "" Then
MsgBox "Os campos CATEGORIA DA DESPESA, DESPESA e VALOR São Obrigatórios!", vbCritical, "CAMPOS VAZIOS"
Exit Sub
End If
End If
Do Until shtDados.Cells(linha, "A") = ""
linha = linha + 1
conte = conte + 1
Loop
shtDados.Cells(linha, "A") = conte
shtDados.Cells(linha, "B") = shtPainel.Range("CategoriaDespesa").Value
If shtPainel.Range("Receita") = "" Then
shtDados.Cells(linha, "C") = shtPainel.Range("Despesa").Value
shtDados.Cells(linha, "D") = "Despesa"
Else
shtDados.Cells(linha, "C") = shtPainel.Range("Receita").Value
shtDados.Cells(linha, "D") = "Receita"
End If
shtDados.Cells(linha, "E") = shtPainel.Range("Valor").Value
If Format(Now, "dd/mm/yyyy") <= shtDados.Cells(linha, "I") Then ' Dt Registro <= Dt Venc. = NO PRAZO
shtDados.Cells(linha, "I") = shtPainel.Range("DtVenc") & " VENCIDO" '.Value
MsgBox "Vencido"
Else
shtDados.Cells(linha, "I") = shtPainel.Range("DtVenc") & " NO PRAZO" '.Value
MsgBox "No Prazo"
End If
shtDados.Cells(linha, "I") = shtPainel.Range("DtVenc").Value
shtDados.Cells(linha, "J") = shtPainel.Range("DtPag").Value
If shtPainel.Range("Mes") = "" Then
shtDados.Cells(linha, "F") = MonthName(Month(Now))
Else
shtDados.Cells(linha, "F") = LCase(shtPainel.Range("Mes").Value)
End If
If shtPainel.Range("Ano") = "" Then
shtDados.Cells(linha, "G") = Year(Now)
Else
shtDados.Cells(linha, "G") = shtPainel.Range("Ano").Value
End If
shtDados.Cells(linha, "H") = Format(Now, "dd/mm/yyyy")
shtDados.Cells(linha, "L") = shtPainel.Range("Obs").Value '(LINHA, "I")
'If shtDados.Cells(linha, "D") = "Despesa" Then
'shtDados.Cells(linha, "E") = shtPainel.Range("Valor").Value * -1
'Else
'shtDados.Cells(linha, "E") = shtPainel.Range("Valor").Value
'End If
MsgBox "Lançamento Completado com Sucesso", vbInformation, "LANÇAMENTOS"
Application.ThisWorkbook.Save
LimparCampos
Application.ScreenUpdating = True
End Sub
Fico na espera de uma ajuda para este problema.
Vou colocar a planilha completa em anexo.
Um Feliz Ano Novo para todos e um ano cheio de prosperidades, saúde e paz para todos e seus familiares.
Bom dia
Professor GURU,
Sou um principiante em VBA com macro nos meus conhecimentos que são pouco foram todos pela internet no youtube e outros sites.
Estou fazendo uma planilha de contas a pagar aqui na empresa que eu trabalho e estou querendo fazer uma situação automática para quando for digitado nas células exemplo H, I,J, I e L a J -> fica a data de registro que automática do sistema, a célula I -> eu lanço a data de Vencimento a célula J é a data da Confirmação do Pagamento e a célula seguinte que é a L -> é a SITUAÇÃO ou STATOS.
Como seria o resultados deste macro é o seguinte:
Exemplo: " H <= I " Resultado é --> NO PRAZO
" H > I " Resultado é --> VENCIDO
" L > "" " Resultado é --> PAGO
Tudo isso é a traveis de um BOTÃO Adicionar, como este macro do botão.
'PROCEDIMENTO PARA ADICIONAR DADOS AO BD
Public Sub Adicionar()
Dim linha As Integer
Dim conte As Integer
Application.ScreenUpdating = False
linha = 4
conte = 1
If shtPainel.Range("A6") = 1 Then
If shtPainel.Range("Receita") = "" Or shtPainel.Range("Valor") = "" Then
MsgBox "Os campos RECEITA e VALOR São Obrigatórios!", vbCritical, "CAMPOS VAZIOS"
Exit Sub
End If
Else
If shtPainel.Range("CategoriaDespesa") = "" Or shtPainel.Range("Despesa") = "" Or shtPainel.Range("Valor") = "" Then
MsgBox "Os campos CATEGORIA DA DESPESA, DESPESA e VALOR São Obrigatórios!", vbCritical, "CAMPOS VAZIOS"
Exit Sub
End If
End If
Do Until shtDados.Cells(linha, "A") = ""
linha = linha + 1
conte = conte + 1
Loop
shtDados.Cells(linha, "A") = conte
shtDados.Cells(linha, "B") = shtPainel.Range("CategoriaDespesa").Value
If shtPainel.Range("Receita") = "" Then
shtDados.Cells(linha, "C") = shtPainel.Range("Despesa").Value
shtDados.Cells(linha, "D") = "Despesa"
Else
shtDados.Cells(linha, "C") = shtPainel.Range("Receita").Value
shtDados.Cells(linha, "D") = "Receita"
End If
shtDados.Cells(linha, "E") = shtPainel.Range("Valor").Value
If Format(Now, "dd/mm/yyyy") <= shtDados.Cells(linha, "I") Then ' Dt Registro <= Dt Venc. = NO PRAZO
shtDados.Cells(linha, "I") = shtPainel.Range("DtVenc") & " VENCIDO" '.Value
MsgBox "Vencido"
Else
shtDados.Cells(linha, "I") = shtPainel.Range("DtVenc") & " NO PRAZO" '.Value
MsgBox "No Prazo"
End If
shtDados.Cells(linha, "I") = shtPainel.Range("DtVenc").Value
shtDados.Cells(linha, "J") = shtPainel.Range("DtPag").Value
If shtPainel.Range("Mes") = "" Then
shtDados.Cells(linha, "F") = MonthName(Month(Now))
Else
shtDados.Cells(linha, "F") = LCase(shtPainel.Range("Mes").Value)
End If
If shtPainel.Range("Ano") = "" Then
shtDados.Cells(linha, "G") = Year(Now)
Else
shtDados.Cells(linha, "G") = shtPainel.Range("Ano").Value
End If
shtDados.Cells(linha, "H") = Format(Now, "dd/mm/yyyy")
shtDados.Cells(linha, "L") = shtPainel.Range("Obs").Value '(LINHA, "I")
'If shtDados.Cells(linha, "D") = "Despesa" Then
'shtDados.Cells(linha, "E") = shtPainel.Range("Valor").Value * -1
'Else
'shtDados.Cells(linha, "E") = shtPainel.Range("Valor").Value
'End If
MsgBox "Lançamento Completado com Sucesso", vbInformation, "LANÇAMENTOS"
Application.ThisWorkbook.Save
LimparCampos
Application.ScreenUpdating = True
End Sub
Fico na espera de uma ajuda para este problema.
Vou colocar a planilha completa em anexo.
Um Feliz Ano Novo para todos e um ano cheio de prosperidades, saúde e paz para todos e seus familiares.
Você não está autorizado a ver ou baixar esse anexo.