Notifications
Clear all

Textbox Valor - Preencher Colunas Entrada e Saida

3 Posts
2 Usuários
0 Reactions
1,223 Visualizações
(@divinors)
Posts: 0
New Member
Topic starter
 

Olá amigos!!!

Tenho uma textbox (txt_valor) que recebe valores de Entrada e Saida e gostaria de gravar esses valores nas colunas 7 e 8 respectivamente.

1-Com os códigos 900,901, 902 e 903 serão os códigos de Entrada de Recursos. (Os valores desses lançamentos serão gravados na Plan6 Coluna 7)

2- Com os códigos 1000 a 8008 serão os códigos de Saida de Recursos. (Os valores desse lançamentos serão gravados na Plan6 Coluna 8)

3-Se alguém tiver alguma rotina semelhante. Ou mesmo me ajudar a modificar o código abaixo. Ficarei grato!!!!

Att.
Divino Rodrigues

Private Sub BtCadastro_Click()
Dim linha As Long

linha = Sheets("1-DADOS").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Row
Plan6.Cells(linha, 1).Value = Me.txt_cod.Value
Plan6.Cells(linha, 2).Value = cb_mes.Value
Plan6.Cells(linha, 3).Value = Me.txt_dia.Value
Plan6.Cells(linha, 4).Value = Me.txt_historico.Value
Plan6.Cells(linha, 5).Value = Me.txt_codigo.Value
Plan6.Cells(linha, 6).Value = Me.txt_parcela.Value
Plan6.Cells(linha, 7).Value = CDbl(Me.txt_valor.Value)
Plan6.Cells(linha, 8).Value = Me.txt_tipo.Value
Plan6.Cells(linha, 9).Value = Me.txt_status.Value

 
Postado : 06/03/2017 7:26 pm
(@jpedro)
Posts: 0
New Member
 

Boa noite!

Não cheguei a abri a sua pasta, mas acredito que se vc inseri da forma abaixo resolve:

Private Sub BtCadastro_Click()
Dim linha As Long

linha = Sheets("1-DADOS").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Row

If (txt_codigo.Value = 900 Or txt_codigo.Value = 901 Or txt_codigo.Value = 902 Or txt_codigo.Value = 903) Then c = 7
If (txt_codigo.Value = 1000 Or txt_codigo.Value = 8008) Then c = 8


Plan6.Cells(linha, 1).Value = Me.txt_cod.Value
Plan6.Cells(linha, 2).Value = cb_mes.Value
Plan6.Cells(linha, 3).Value = Me.txt_dia.Value
Plan6.Cells(linha, 4).Value = Me.txt_historico.Value
Plan6.Cells(linha, 5).Value = Me.txt_codigo.Value
Plan6.Cells(linha, 6).Value = Me.txt_parcela.Value
Plan6.Cells(linha, c).Value = CDbl(Me.txt_valor.Value)
Plan6.Cells(linha, 8).Value = Me.txt_tipo.Value
Plan6.Cells(linha, 9).Value = Me.txt_status.Value

Mas se vc tem muitos códigos, melhor colocar a condição True para o que tem menos e o "Else" para o que tem mais. Ex.:

If (txt_codigo.Value = 900 Or txt_codigo.Value = 901 Or txt_codigo.Value = 902 Or txt_codigo.Value = 903) Then 
c = 7
Else
c = 8
End if

Ou ainda: vc relaciona os códigos em uma planilha e insere, por exemplo:

If Application.WorksheetFunction.CountIf(PlanXYZ.Range("A:A"), txt_codigo.Value) > 0 Then 
c = 6
Else
c = 7
End If

Abs!

 
Postado : 06/03/2017 9:03 pm
(@divinors)
Posts: 0
New Member
Topic starter
 

Utilizei o primeiro código e funcionou!!! Obrigado!!!!!

Att.
Divino Rodrigues

 
Postado : 07/03/2017 12:33 pm