Ir ao conteúdo
  • Cadastre-se

Excel botão de comando editar vba


Posts recomendados

Alguém poderia me dar uma mãozinha com esse código para editar planilha, eu já revirei a internet tentando"

Planilha7.Activate

'percorre dados da planilha
Do While ActiveCell.Value <> ""
 If ActiveCell.Value = textcodforn Then

    ActiveCell.Value = textcodforn.Value
    ActiveCell.Offset(0, 2).Value = textcnpjfor.Value
    ActiveCell.Offset(0, 3).Value = textrazaosocialfor.Value
    ActiveCell.Offset(0, 4).Value = textendfor.Value
    ActiveCell.Offset(0, 5).Value = textnfor.Value
    ActiveCell.Offset(0, 6).Value = textcomplementofor.Value
    ActiveCell.Offset(0, 7).Value = textbairrofor.Value
    ActiveCell.Offset(0, 8).Value = textcidadefor.Value
    ActiveCell.Offset(0, 9).Value = cbuffor.Value
    ActiveCell.Offset(0, 10).Value = textcontatofor.Value
    ActiveCell.Offset(0, 11).Value = texttelefonefor.Value
    ActiveCell.Offset(0, 12).Value = textcelularfor.Value
    
    End If
    ActiveCell.Offset(1, 0).Select
    
 
 Loop
 
  

    
     MsgBox "Dados alterados com sucesso!", vbInformation, "São Geraldo 1.0"
    
    textcodforn = ""
    textcnpjfor = ""
    textrazaosocialfor = ""
    textendfor = ""
    textnfor = ""
    textcomplementofor = ""
    textbairrofor = ""
    textcidadefor = ""
    cbuffor = ""
    textcontatofor = ""
    texttelefonefor = ""
    textcelularfor = ""
    cblocalizarforn = ""
    
End Sub

 

Link para o comentário
Compartilhar em outros sites

  • 1 ano depois...
Em 30/10/2017 às 18:14, Patropi disse:

Boa noite Camila

 

Seja bem-vinda ao fórum!

 

Para facilitar anexe a planilha e dê explicações do que você deseja.

 

[]s

Boa noite Patropi,

Sou iniciante em vba, montei um projeto a pedido de um amigo, ficou meio "Frankenstein" rsrsrs, porque peguei um pouco de cada vídeo que vi no youtube, (ainda vou fazer o curso de excel vba) só que quando chegou no botão editar enfrentei o mesmo problema da Camila, não consigo fazer funcionar direito, tentei vários códigos que achei na internet, até tentei adaptar de outros projetos, mas não funciona, a ultima tentativa que fiz o código só altera a célula da linha, ou só altera o restante das células da linha e faz o mesmo com outra que tiver com dados iguais, e não altera a primeira célula.... não sei se me fiz entender....rsrsrs, faz dias que estou tentando achar algo no youtube, em fóruns e nada.

Por favor, se puder me ajudar fico muito agradecida.

 

Vou colocar só a parte do código do botão editar que está com essa falha, mas vou anexar o projeto também.

 

Private Sub BOTAO_EDITAR_Click()

 

'====O PROBLEMA COMEÇA AQUI====

Range("A2:BW2").Select

While ActiveCell <> ""

If COMBO_LOCCLIENTE = ActiveCell Then

ActiveCell.Value = CAIXA_CLIENTE.Text 'se ActiveCell.Value = CAIXA_CLIENTE.Text fica desativada
'com a aspas simples o comando faz as alterações somente nas celulas seguintes a ela e também
'altera outras que possuam os mesmos dados, se ActiveCell.Value = CAIXA_CLIENTE.Text fica ativada
'só altera ela mesma.

ActiveCell.Offset(0, 1).Value = CAIXA_CPF.Text
ActiveCell.Offset(0, 2).Value = CAIXA_CNPJ.Text
ActiveCell.Offset(0, 3).Value = CAIXA_VEICULO.Text
ActiveCell.Offset(0, 4).Value = CAIXA_PLACA.Text
ActiveCell.Offset(0, 5).Value = COMBO_DDD.Text
ActiveCell.Offset(0, 6).Value = CAIXA_TELCELL.Text
ActiveCell.Offset(0, 7).Value = CAIXA_EMAIL.Text
ActiveCell.Offset(0, 8).Value = CAIXA_ENDERECO.Text
ActiveCell.Offset(0, 9).Value = CAIXA_CEP.Text
ActiveCell.Offset(0, 10).Value = CAIXA_CIDADE.Text
ActiveCell.Offset(0, 11).Value = COMBO_UF.Text
ActiveCell.Offset(0, 12).Value = OPTION_GOOGLE.Value
ActiveCell.Offset(0, 13).Value = OPTION_FACEBOOK.Value
ActiveCell.Offset(0, 14).Value = OPTION_INSTAGRAN.Value
ActiveCell.Offset(0, 15).Value = OPTION_RADIO.Value
ActiveCell.Offset(0, 16).Value = OPTION_PANFLETO.Value
ActiveCell.Offset(0, 17).Value = OPTION_INDICACAO.Value
ActiveCell.Offset(0, 18).Value = CAIXA_INDICACAO.Text
ActiveCell.Offset(0, 19).Value = CAIXA_RESPONSAVEL.Text
ActiveCell.Offset(0, 20).Value = CHECK_BANCO.Value
ActiveCell.Offset(0, 21).Value = CHECK_LEGITIMO.Value
ActiveCell.Offset(0, 22).Value = CHECK_ECOLOGICO.Value
ActiveCell.Offset(0, 23).Value = CAIXA_QUANT_L1.Text
ActiveCell.Offset(0, 24).Value = CAIXA_VLUNIT_L1.Value
ActiveCell.Offset(0, 25).Value = CAIXA_VLTOTAL_L1.Value
ActiveCell.Offset(0, 26).Value = CHECK_VOLANTE.Value
ActiveCell.Offset(0, 27).Value = CAIXA_QUANT_L2.Text
ActiveCell.Offset(0, 28).Value = CAIXA_VLUNIT_L2.Value
ActiveCell.Offset(0, 29).Value = CAIXA_VLTOTAL_L2.Value
ActiveCell.Offset(0, 30).Value = CHECK_CARPETE.Value
ActiveCell.Offset(0, 31).Value = CAIXA_QUANT_L3.Text
ActiveCell.Offset(0, 32).Value = CAIXA_VLUNIT_L3.Value
ActiveCell.Offset(0, 33).Value = CAIXA_VLTOTAL_L3.Value
ActiveCell.Offset(0, 34).Value = CHECK_TETO.Value
ActiveCell.Offset(0, 35).Value = CAIXA_QUANT_L4.Text
ActiveCell.Offset(0, 36).Value = CAIXA_VLUNIT_L4.Value
ActiveCell.Offset(0, 37).Value = CAIXA_VLTOTAL_L4.Value
ActiveCell.Offset(0, 38).Value = CHECK_LIMPSECO.Value
ActiveCell.Offset(0, 39).Value = CAIXA_QUANT_L5.Text
ActiveCell.Offset(0, 40).Value = CAIXA_VLUNIT_L5.Value
ActiveCell.Offset(0, 41).Value = CAIXA_VLTOTAL_L5.Value
ActiveCell.Offset(0, 42).Value = CHECK_LIMPHIDRAT.Value
ActiveCell.Offset(0, 43).Value = CAIXA_QUANT_L6.Text
ActiveCell.Offset(0, 44).Value = CAIXA_VLUNIT_L6.Value
ActiveCell.Offset(0, 45).Value = CAIXA_VLTOTAL_L6.Value
ActiveCell.Offset(0, 46).Value = CHECK_CAPOTA.Value
ActiveCell.Offset(0, 47).Value = CAIXA_QUANT_L7.Text
ActiveCell.Offset(0, 48).Value = CAIXA_VLUNIT_L7.Value
ActiveCell.Offset(0, 49).Value = CAIXA_VLTOTAL_L7.Value
ActiveCell.Offset(0, 50).Value = CAIXA_OUTROSERV1.Text
ActiveCell.Offset(0, 51).Value = CAIXA_QUANT_L8.Text
ActiveCell.Offset(0, 52).Value = CAIXA_VLUNIT_L8.Value
ActiveCell.Offset(0, 53).Value = CAIXA_VLTOTAL_L8.Value
ActiveCell.Offset(0, 54).Value = CAIXA_OUTROSERV2.Text
ActiveCell.Offset(0, 55).Value = CAIXA_QUANT_L9.Text
ActiveCell.Offset(0, 56).Value = CAIXA_VLUNIT_L9.Value
ActiveCell.Offset(0, 57).Value = CAIXA_VLTOTAL_L9.Value
ActiveCell.Offset(0, 58).Value = CAIXA_OUTROSERV3.Text
ActiveCell.Offset(0, 59).Value = CAIXA_QUANT_L10.Text
ActiveCell.Offset(0, 60).Value = CAIXA_VLUNIT_L10.Value
ActiveCell.Offset(0, 61).Value = CAIXA_VLTOTAL_L10.Value
ActiveCell.Offset(0, 62).Value = CAIXA_SUBTOTAL.Value
ActiveCell.Offset(0, 63).Value = CAIXA_DESCONTO_2.Text
ActiveCell.Offset(0, 64).Value = CAIXA_DESCONTO.Value
ActiveCell.Offset(0, 65).Value = CAIXA_TOTAL.Value
ActiveCell.Offset(0, 66).Value = CHECK_AVISTA.Value
ActiveCell.Offset(0, 67).Value = COMBO_AVISTA.Text
ActiveCell.Offset(0, 68).Value = CHECK_PARCELADO.Value
ActiveCell.Offset(0, 69).Value = COMBO_PARCELADO.Text
ActiveCell.Offset(0, 70).Value = CAIXA_OBSERVACAO.Text
ActiveCell.Offset(0, 71).Value = CAIXA_DATA.Text
ActiveCell.Offset(0, 72).Value = ORC_SIM_NAO.Text
ActiveCell.Offset(0, 73).Value = PED_SIM_NAO.Text
ActiveCell.Offset(0, 74).Value = REC_SIM_NAO.Text
End If
ActiveCell.Offset(1, 0).Activate
Wend

'======O PROBLEMA TERMINA AQUI===========

 

 

ORDEM_ALFABETICA

'Mensagem de gravação concluída
MsgBox "Dados Alterdos com Sucesso"

'Limpeza de caixas, depois de tudo gravado com sucesso
CAIXA_CLIENTE = Empty
CAIXA_CPF = Empty
CAIXA_CNPJ = Empty
CAIXA_VEICULO = Empty
CAIXA_PLACA = Empty
COMBO_DDD = Empty
CAIXA_TELCELL = Empty
CAIXA_EMAIL = Empty
CAIXA_ENDERECO = Empty
CAIXA_CEP = Empty
CAIXA_CIDADE = Empty
COMBO_UF = Empty
OPTION_GOOGLE = False
OPTION_FACEBOOK = False
OPTION_INSTAGRAN = False
OPTION_RADIO = False
OPTION_PANFLETO = False
OPTION_INDICACAO = False
CAIXA_INDICACAO = Empty
CAIXA_RESPONSAVEL = Empty
CHECK_BANCO = False
CHECK_LEGITIMO = False

CHECK_ECOLOGICO = False
CAIXA_QUANT_L1 = 0
CAIXA_VLUNIT_L1 = 0
CAIXA_VLTOTAL_L1 = 0

CHECK_VOLANTE = False
CAIXA_QUANT_L2 = 0
CAIXA_VLUNIT_L2 = 0
CAIXA_VLTOTAL_L2 = 0

CHECK_CARPETE = False
CAIXA_QUANT_L3 = 0
CAIXA_VLUNIT_L3 = 0
CAIXA_VLTOTAL_L3 = 0

CHECK_TETO = False
CAIXA_QUANT_L4 = 0
CAIXA_VLUNIT_L4 = 0
CAIXA_VLTOTAL_L4 = 0

CHECK_LIMPSECO = False
CAIXA_QUANT_L5 = 0
CAIXA_VLUNIT_L5 = 0
CAIXA_VLTOTAL_L5 = 0

CHECK_LIMPHIDRAT = False
CAIXA_QUANT_L6 = 0
CAIXA_VLUNIT_L6 = 0
CAIXA_VLTOTAL_L6 = 0

CHECK_CAPOTA = False
CAIXA_QUANT_L7 = 0
CAIXA_VLUNIT_L7 = 0
CAIXA_VLTOTAL_L7 = 0

CAIXA_OUTROSERV1 = Empty
CAIXA_QUANT_L8 = 0
CAIXA_VLUNIT_L8 = 0
CAIXA_VLTOTAL_L8 = 0

CAIXA_OUTROSERV2 = Empty
CAIXA_QUANT_L9 = 0
CAIXA_VLUNIT_L9 = 0
CAIXA_VLTOTAL_L9 = 0

CAIXA_OUTROSERV3 = Empty
CAIXA_QUANT_L10 = 0
CAIXA_VLUNIT_L10 = 0
CAIXA_VLTOTAL_L10 = 0

CAIXA_SUBTOTAL = Empty
CAIXA_DESCONTO_2 = 0
CAIXA_DESCONTO = 0
CAIXA_TOTAL = Empty

CHECK_AVISTA = False
CHECK_PARCELADO = False
COMBO_PARCELADO = Empty
COMBO_LOCCLIENTE = Empty
COMBO_LOCPLACA = Empty
COMBO_LOCTELCELL = Empty
COMBO_LOCDATA = Empty
CAIXA_OBSERVACAO = Empty
CAIXA_DATA = Empty
ORC_SIM_NAO = Empty
PED_SIM_NAO = Empty
REC_SIM_NAO = Empty

'Formato de moeda já no inicio, ativado também no limpar, salvar, excluir
CAIXA_VLUNIT_L1.Value = Format(CAIXA_VLUNIT_L1.Text, "Currency")
CAIXA_VLUNIT_L2.Value = Format(CAIXA_VLUNIT_L2.Text, "Currency")
CAIXA_VLUNIT_L3.Value = Format(CAIXA_VLUNIT_L3.Text, "Currency")
CAIXA_VLUNIT_L4.Value = Format(CAIXA_VLUNIT_L4.Text, "Currency")
CAIXA_VLUNIT_L5.Value = Format(CAIXA_VLUNIT_L5.Text, "Currency")
CAIXA_VLUNIT_L6.Value = Format(CAIXA_VLUNIT_L6.Text, "Currency")
CAIXA_VLUNIT_L7.Value = Format(CAIXA_VLUNIT_L7.Text, "Currency")
CAIXA_VLUNIT_L8.Value = Format(CAIXA_VLUNIT_L8.Text, "Currency")
CAIXA_VLUNIT_L9.Value = Format(CAIXA_VLUNIT_L9.Text, "Currency")
CAIXA_VLUNIT_L10.Value = Format(CAIXA_VLUNIT_L10.Text, "Currency")

CAIXA_VLTOTAL_L1.Value = Format(CAIXA_VLTOTAL_L1.Text, "Currency")
CAIXA_VLTOTAL_L2.Value = Format(CAIXA_VLTOTAL_L2.Text, "Currency")
CAIXA_VLTOTAL_L3.Value = Format(CAIXA_VLTOTAL_L3.Text, "Currency")
CAIXA_VLTOTAL_L4.Value = Format(CAIXA_VLTOTAL_L4.Text, "Currency")
CAIXA_VLTOTAL_L5.Value = Format(CAIXA_VLTOTAL_L5.Text, "Currency")
CAIXA_VLTOTAL_L6.Value = Format(CAIXA_VLTOTAL_L6.Text, "Currency")
CAIXA_VLTOTAL_L7.Value = Format(CAIXA_VLTOTAL_L7.Text, "Currency")
CAIXA_VLTOTAL_L8.Value = Format(CAIXA_VLTOTAL_L8.Text, "Currency")
CAIXA_VLTOTAL_L9.Value = Format(CAIXA_VLTOTAL_L9.Text, "Currency")
CAIXA_VLTOTAL_L10.Value = Format(CAIXA_VLTOTAL_L10.Text, "Currency")

CAIXA_SUBTOTAL.Value = Format(CAIXA_SUBTOTAL.Text, "Currency")
CAIXA_DESCONTO.Value = Format(CAIXA_DESCONTO.Text, "Currency")
CAIXA_TOTAL.Value = Format(CAIXA_TOTAL.Text, "Currency")

ORC_SIM_NAO.SetFocus

Exit Sub
End Sub

 

Só falta isso pra eu entregar.

Por gentileza, fico no aguardo e desde já agradeço.

Att,Geislaine

 

24 11 2018 - tentativa botao editar - enviar para forum.rar

Link para o comentário
Compartilhar em outros sites

Crie uma conta ou entre para comentar

Você precisa ser um usuário para fazer um comentário

Criar uma conta

Crie uma nova conta em nossa comunidade. É fácil!

Crie uma nova conta

Entrar

Já tem uma conta? Faça o login.

Entrar agora

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...