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.
  • Avatar do usuário
  • Avatar do usuário
Por Voiiz
#12380
Boa Noite ! Pessoal tudo bem ? Sou novo aqui. Estou criando uma planilha de fluxo de caixa e ela estava pronta ate o momento, mas sempre vem uma nova ideia, pois bem vamos a essa nova ideia.

Minha planilha lança Despesas e Receitas por VBA. Ao lançar uma Despesa que seja PARCELADA queria que ao lançar ela na aba onde recebem os DADOS recebe os dados e as possiveis parcelas. Digamos

COMPREI 1 TÊNIS DA NIKE EM 10X NO VALOR DE R$1000,00

Na aba DADOS hoje recebe desta maneira

Código: Selecionar todos
0001	CartãodeCrédito	Santander	TENIS NIKE	Despesa	10	999,00	maio	2016	30/06/2016	30/06/2016	09/07/2016
Pois bem ao tentar lançar as parcelas queria que a aba DADOS recebe-se desta forma



Código: Selecionar todos
0002	CartãodeCrédito	Santander	TENIS NIKE	Despesa	1	100,00	maio		2016	30/06/2016	30/06/2016	09/07/2016

0003	CartãodeCrédito	Santander	TENIS NIKE	Despesa	2	100,00	junho		2016	30/06/2016	30/06/2016	09/08/2016

0004	CartãodeCrédito	Santander	TENIS NIKE	Despesa	3	100,00	julho		2016	30/06/2016	30/06/2016	09/09/2016

0005	CartãodeCrédito	Santander	TENIS NIKE	Despesa	4	100,00	agosto	2016	30/06/2016	30/06/2016	09/10/2016

0006	CartãodeCrédito	Santander	TENIS NIKE	Despesa	5	100,00	setembro	2016	30/06/2016	30/06/2016	09/11/2016

0007	CartãodeCrédito	Santander	TENIS NIKE	Despesa	6	100,00	outubro	2016	30/06/2016	30/06/2016	09/12/2016

0008	CartãodeCrédito	Santander	TENIS NIKE	Despesa	7	100,00	novembro	2016	30/06/2016	30/06/2016	09/01/2017

0009	CartãodeCrédito	Santander	TENIS NIKE	Despesa	8	100,00	dezembro	2016	30/06/2016	30/06/2016	09/02/2017

0010	CartãodeCrédito	Santander	TENIS NIKE	Despesa	9	100,00	janeiro	2016	30/06/2016	30/06/2016	09/03/2017

0011	CartãodeCrédito	Santander	TENIS NIKE	Despesa	10	100,00	fevereiro	2016	30/06/2016	30/06/2016	09/04/2017




Vou disponibilizar a planilha para melhor entendimento visual... estes lançamentos mensais eu fiz um por um. Também estava criando uma mensagem visual para perguntar sobre o lançamento, mas não o finalizei
Avatar do usuário
Por Reinaldo
Avatar
#12589
Uma possibilidade:
Código: Selecionar todos
.......
If DESPESA = vbNo Then MsgBox "Não erre o Lançamento das Despesas"

If DESPESA = vbYes Then

    If shtPainel.Range("Receita") = "" Then
        For x = 1 To shtPainel.Range("QntdParcelas").Value
            shtDados.Cells(Linha, "A") = Conte
            shtDados.Cells(Linha, "B") = shtPainel.Range("CategoriaDespesa").Value
            shtDados.Cells(Linha, "C") = shtPainel.Range("Despesa").Value
            shtDados.Cells(Linha, "E") = "Despesa"
            shtDados.Cells(Linha, "J") = CDate(Format(Now, "dd/mm/yyyy"))
            shtDados.Cells(Linha, "K") = shtPainel.Range("DatacOMPRA").Value
            If x = 1 Then
                shtDados.Cells(Linha, "L") = CDate(shtPainel.Range("DataVencimento").Value)
            Else
                shtDados.Cells(Linha, "L") = VBA.DateAdd("m", x - 1, CDate(shtPainel.Range("DataVencimento")))
            End If
            shtDados.Cells(Linha, "D") = shtPainel.Range("Descrição").Value
            shtDados.Cells(Linha, "F") = x 'shtPainel.Range("QntdParcelas").Value
            shtDados.Cells(Linha, "G") = shtPainel.Range("Valor").Value / shtPainel.Range("QntdParcelas").Value
        
            If shtPainel.Range("Mes") = "" Then
                shtDados.Cells(Linha, "H") = MonthName(Month(Now))
            Else
                shtDados.Cells(Linha, "H") = LCase(shtPainel.Range("Mes").Value)
            End If
    
            If shtPainel.Range("Ano") = "" Then
                shtDados.Cells(Linha, "I") = Year(Now)
            Else
                shtDados.Cells(Linha, "I") = shtPainel.Range("Ano").Text
            End If
        Conte = Conte + 1
        Linha = Linha + 1
        Next
    End If
    MsgBox "Lançamento da Despesa Efetuado"
End If

'End If.....
Por Voiiz
#12821
Meu caro!! A questão dos meses teria como eles mudarem ? Eu fiz e ficou Show, mas o MÊS em si "JUNHO.JULHO...." eles não mudam. Como eu poderia fazer isso ? Eu fiz um teste mas acabei ferrando toda planilha :'( não sei como o FOR funciona
Reinaldo escreveu:Uma possibilidade:
Código: Selecionar todos
.......
If DESPESA = vbNo Then MsgBox "Não erre o Lançamento das Despesas"

If DESPESA = vbYes Then

    If shtPainel.Range("Receita") = "" Then
        For x = 1 To shtPainel.Range("QntdParcelas").Value
            shtDados.Cells(Linha, "A") = Conte
            shtDados.Cells(Linha, "B") = shtPainel.Range("CategoriaDespesa").Value
            shtDados.Cells(Linha, "C") = shtPainel.Range("Despesa").Value
            shtDados.Cells(Linha, "E") = "Despesa"
            shtDados.Cells(Linha, "J") = CDate(Format(Now, "dd/mm/yyyy"))
            shtDados.Cells(Linha, "K") = shtPainel.Range("DatacOMPRA").Value
            If x = 1 Then
                shtDados.Cells(Linha, "L") = CDate(shtPainel.Range("DataVencimento").Value)
            Else
                shtDados.Cells(Linha, "L") = VBA.DateAdd("m", x - 1, CDate(shtPainel.Range("DataVencimento")))
            End If
            shtDados.Cells(Linha, "D") = shtPainel.Range("Descrição").Value
            shtDados.Cells(Linha, "F") = x 'shtPainel.Range("QntdParcelas").Value
            shtDados.Cells(Linha, "G") = shtPainel.Range("Valor").Value / shtPainel.Range("QntdParcelas").Value
        
            If shtPainel.Range("Mes") = "" Then
                shtDados.Cells(Linha, "H") = MonthName(Month(Now))
            Else
                shtDados.Cells(Linha, "H") = LCase(shtPainel.Range("Mes").Value)
            End If
    
            If shtPainel.Range("Ano") = "" Then
                shtDados.Cells(Linha, "I") = Year(Now)
            Else
                shtDados.Cells(Linha, "I") = shtPainel.Range("Ano").Text
            End If
        Conte = Conte + 1
        Linha = Linha + 1
        Next
    End If
    MsgBox "Lançamento da Despesa Efetuado"
End If

'End If.....
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