Notifications
Clear all

Ativar Campos do Formulario no Cadastro de Clientes

9 Posts
4 Usuários
0 Reactions
1,262 Visualizações
Fernando Fernandes
(@fernandofernandes)
Posts: 43750
Illustrious Member
Topic starter
 

Ola!
Através de uma planilha já existente eu editei para usar para meu cadastro de Clientes Imobiliários e Advocacia.
Criei os campos no formulário para inserir as informações que preciso, só que não sei fazer com que a Informação colocada já para ser gravado no intervalo correto.

O que Preciso :
Mudar o acionamento da Macro de Planilha, para ser ativada na CAPA
Que os campos do formulário gravem e direcionem as informações para as células

Ou se for possível me explicar como que faria isso!

Obrigado!

Existem mil maneiras de preparar Neston. Invente a sua!
http://www.youtube.com/ExpressoExcel

 
Postado : 04/02/2016 4:51 am
(@fabiosp)
Posts: 291
Reputable Member
 

Olá

Você quer que o formulário para cadastro de clientes seja acionado pela aba CAPA e os dados que for inseridos sejam copiados para Dados Clientes?
Se for isso acho que posso ajudar!

Abraços.

 
Postado : 04/02/2016 6:55 am
(@robo8268)
Posts: 73
Trusted Member
 

Eu não entendi a sua solicitação, você quer que a macro seja habilitada quando a aba CAPA for ativada?

Se for isso, basta clicar no módulo com o nome da planilha, selecionar no combo localizado na parte de cima, a opção worksheet, e no combo ao lado, a opção Activate.
depois dentro do bloco do evento Activate, digite Call nomedamacro

 
Postado : 04/02/2016 8:01 am
fcarlosc
(@fcarlosc)
Posts: 453
Honorable Member
 

Olá amigo.
Você pode inserir um módulo e colar esse código, e ou adaptá-lo.

Public Sub Cadastro()

Dados.Show

End Sub

Vai na "Plan" clica com o direito no botão "Cadastro" atribuir macro e escola a macro "Cadastro".

att,

Francisco

 
Postado : 04/02/2016 8:28 am
Fernando Fernandes
(@fernandofernandes)
Posts: 43750
Illustrious Member
Topic starter
 

Olá

Você quer que o formulário para cadastro de clientes seja acionado pela aba CAPA e os dados que for inseridos sejam copiados para Dados Clientes?
Se for isso acho que posso ajudar!

Abraços.

é isso mesmo, gostaria que o botão que abre o formulário estivesse na CAPA e quando preenchesse o formulário continuasse na CAPA.

Existem mil maneiras de preparar Neston. Invente a sua!
http://www.youtube.com/ExpressoExcel

 
Postado : 04/02/2016 3:09 pm
Fernando Fernandes
(@fernandofernandes)
Posts: 43750
Illustrious Member
Topic starter
 

Olá!

Reescrevi o codigo VBA com os novos campos que inseri no formulario, mas dá erro 424 na hora de gravar dizendo que o objeto é obrigatorio e marca a linha :

ActiveCell.Offset(0, 6).Value = txtcasa.Value

o que tem de ser feito ?

Private Sub cmdExcluir_Click()
'Declarar a variável Resp para receber uma resposta
Dim Resp As Integer
'Fazer a busca do registro digitado pelo usuário
With Worksheets("Dados Clientes").Range("A:A")
Set c = .Find(txtCPF.Value, LookIn:=xlValues, LookAt:=xlWhole)
If Not c Is Nothing Then
Resp = MsgBox("Tem certeza que deseja excluir o registro?", vbYesNo, "Confirmação")
If Resp = vbYes Then
c.Select
Selection.EntireRow.Delete
'Limpar as caixas de texto
txtCPF.Value = Empty
txtorigem.Value = Empty
txtNome.Value = Empty
txtacao.Value = Empty
txtrua.Value = Empty
txtnumero.Value = Empty
txtbairro.Value = Empty
txtcasa.Value = Empty
txttelefone1.Value = Empty
txttelefone2.Value = Empty
txttelefone3.Value = Empty
txtdatainicioprocesso.Value = Empty
txtprimeiraaudiencia.Value = Empty
txtsegundaaudiencia.Value = Empty
txtfaseatualprocesso.Value = Empty
txtvalorpretendido.Value = Empty
txtgastosnoprocesso.Value = Empty
txtvalordeacordo.Value = Empty
txtformaderecebimento.Value = Empty
txtquantidadedeparcelas.Value = Empty
txtapartirde.Value = Empty
txtiniciodocontrato.Value = Empty
txtterminodocontrato.Value = Empty
txtvalordealuguel.Value = Empty
txtdataproximoreajuste.Value = Empty
txtcontratoassinado.Value = Empty
txtdiadepagamento.Value = Empty
txtObservações.Value = Empty
'Colocar o foco na primeira caixa de texto
txtCPF.SetFocus
Else
MsgBox "O registro não será excluído!"
End If
Else
MsgBox "Cliente não encontrado!"
End If
End With
Exit Sub

End Sub

Private Sub cmdFechar_Click()
Dados.Hide
End Sub

Private Sub cmdGravar_Click()

'Ativar a primeira planilha
ThisWorkbook.Worksheets("Dados Clientes").Activate
'Selecionar a célula A3
Range("A3").Select

'Procurar a primeira célula vazia
Do
If Not (IsEmpty(ActiveCell)) Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = True

'Carregar os dados digitados nas caixas de texto para a planilha
ActiveCell.Value = txtCPF.Value
ActiveCell.Offset(0, 1).Value = txtorigem.Value
ActiveCell.Offset(0, 2).Value = txtNome.Value
ActiveCell.Offset(0, 3).Value = txtacao.Value
ActiveCell.Offset(0, 4).Value = txtrua.Value
ActiveCell.Offset(0, 5).Value = txtnumero.Value
ActiveCell.Offset(0, 5).Value = txtbairro.Value
ActiveCell.Offset(0, 6).Value = txtcasa.Value
ActiveCell.Offset(0, 7).Value = txttelefone1.Value
ActiveCell.Offset(0, 8).Value = txttelefone2.Value
ActiveCell.Offset(0, 9).Value = txttelefone3.Value
ActiveCell.Offset(0, 10).Value = txtdatainicioprocesso.Value
ActiveCell.Offset(0, 11).Value = txtprimeiraaudiencia.Value
ActiveCell.Offset(0, 12).Value = txtsegundaaudiencia.Value
ActiveCell.Offset(0, 13).Value = txtfaseatualprocesso.Value
ActiveCell.Offset(0, 14).Value = txtvalorpretendido.Value
ActiveCell.Offset(0, 15).Value = txtgastosnoprocesso.Value
ActiveCell.Offset(0, 16).Value = txtvalordeacordo.Value
ActiveCell.Offset(0, 17).Value = txtformaderecebimento.Value
ActiveCell.Offset(0, 18).Value = txtquantidadedeparcelas.Value
ActiveCell.Offset(0, 19).Value = txtapartirde.Value
ActiveCell.Offset(0, 20).Value = txtiniciodocontrato.Value
ActiveCell.Offset(0, 21).Value = txtterminodocontrato.Value
ActiveCell.Offset(0, 22).Value = txtvalordealuguel.Value
ActiveCell.Offset(0, 23).Value = txtdataproximoreajuste.Value
ActiveCell.Offset(0, 24).Value = txtcontratoassinado.Value
ActiveCell.Offset(0, 25).Value = txtdiadepagamento.Value
ActiveCell.Offset(0, 26).Value = txtObservações.Value

'Limpar as caixas de texto
txtCPF.Value = Empty
txtorigem.Value = Empty
txtNome.Value = Empty
txtacao.Value = Empty
txtrua.Value = Empty
txtnumero.Value = Empty
txtbairro.Value = Empty
txtcasa.Value = Empty
txttelefone1.Value = Empty
txttelefone2.Value = Empty
txttelefone3.Value = Empty
txtdatainicioprocesso.Value = Empty
txtprimeiraaudiencia.Value = Empty
txtsegundaaudiencia.Value = Empty
txtfaseatualprocesso.Value = Empty
txtvalorpretendido.Value = Empty
txtgastosnoprocesso.Value = Empty
txtvalordeacordo.Value = Empty
txtformaderecebimento.Value = Empty
txtquantidadedeparcelas.Value = Empty
txtapartirde.Value = Empty
txtiniciodocontrato.Value = Empty
txtterminodocontrato.Value = Empty
txtvalordealuguel.Value = Empty
txtdataproximoreajuste.Value = Empty
txtcontratoassinado.Value = Empty
txtdiadepagamento.Value = Empty
txtObservações.Value = Empty

End Sub

Private Sub cmdPequisar_Click()
'Verificar se foi digitado um nome na primeira caixa de texto
If txtCPF.Text = "" Then
MsgBox "Digite o CPF de um cliente"
txtCPF.SetFocus
GoTo Linha1
End If
With Worksheets("Dados Clientes").Range("A:A")
Set c = .Find(txtCPF.Value, LookIn:=xlValues, LookAt:=xlPart)
If Not c Is Nothing Then
c.Activate
txtCPF.Value = c.Value
txtorigem.Value = c.Offset(0, 1).Value
txtNome.Value = c.Offset(0, 2).Value
txtacao.Value = c.Offset(0, 3).Value
txtrua.Value = c.Offset(0, 4).Value
txtnumero.Value = c.Offset(0, 5).Value
txtbairro.Value = c.Offset(0, 6).Value
txtcasa.Value = c.Offset(0, 7).Value
txttelefone1.Value = c.Offset(0, 8).Value
txttelefone2.Value = c.Offset(0, 9).Value
txttelefone3.Value = c.Offset(0, 10).Value
txtdatainicioprocesso.Value = c.Offset(0, 11).Value
txtprimeiraaudiencia.Value = c.Offset(0, 12).Value
txtsegundaaudiencia.Value = c.Offset(0, 13).Value
txtfaseatualprocesso.Value = c.Offset(0, 14).Value
txtvalorpretendido.Value = c.Offset(0, 15).Value
txtgastosnoprocesso.Value = c.Offset(0, 16).Value
txtvalordeacordo.Value = c.Offset(0, 17).Value
txtformaderecebimento.Value = c.Offset(0, 18).Value
txtquantidadedeparcelas.Value = c.Offset(0, 19).Value
txtapartirde.Value = c.Offset(0, 20).Value
txtiniciodocontrato.Value = c.Offset(0, 21).Value
txtterminodocontrato.Value = c.Offset(0, 22).Value
txtvalordealuguel.Value = c.Offset(0, 23).Value
txtdataproximoreajuste.Value = c.Offset(0, 24).Value
txtcontratoassinado.Value = c.Offset(0, 25).Value
txtdiadepagamento.Value = c.Offset(0, 26).Value
txtObservações.Value = c.Offset(0, 27).Value

'Carregando o botão de opção
MsgBox "Cliente encontrado!"
End If
End With
Linha1:
End Sub

Private Sub txtCPF_Change()

End Sub

Existem mil maneiras de preparar Neston. Invente a sua!
http://www.youtube.com/ExpressoExcel

 
Postado : 05/02/2016 7:32 am
fcarlosc
(@fcarlosc)
Posts: 453
Honorable Member
 

Olá amigo.
Dá uma olha no código. Tá repetindo Linha e Coluna.

ActiveCell.Offset(0, 5).Value = txtnumero.Value
ActiveCell.Offset(0, 5).Value = txtbairro.Value

Att,

Francisco

 
Postado : 05/02/2016 8:07 am
Fernando Fernandes
(@fernandofernandes)
Posts: 43750
Illustrious Member
Topic starter
 

Fiz a correção porem o código dá erro de 7 em 7 células na macro Gravar e na Limpar dados.

Existem mil maneiras de preparar Neston. Invente a sua!
http://www.youtube.com/ExpressoExcel

 
Postado : 05/02/2016 8:45 am
fcarlosc
(@fcarlosc)
Posts: 453
Honorable Member
 

Olá amigo.
Esses erros são referentes aos "TextBox", no caso de "txtObservações" eu alterei aqui para "txtObservacoes". Outra foi a "txtcasa" e "txtvalorpretendido".
Dá uma revisada ai...

att,

Francisco

 
Postado : 05/02/2016 9:16 am