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.
#71514
Boa tarde pessoal! Todos bem?

Sou iniciante na prática do VBA e o pouco que sei vou buscando na internet quase sempre (ainda tentando decorar as nomenclaturas). Estou criando um formulário para controle de logística e pensei algo para que o usuário altere somente os dados no userform (e não na tabela da planilha), porém o comando para atualizar registro acaba inserindo como um novo registro e fora da tabela criada para base. Podem me dar um direcionamento por favor?
Você não está autorizado a ver ou baixar esse anexo.
#71662
Bom dia povo!

Encontrei uma solução com um colega em outro fórum e vou postar aqui o código que funcionou para a parte da edição, segue:
Código: Selecionar todos
Sub EDITAR()

BLOQUEADO = True
Dim TABELA As ListObject

Set TABELA = Planilha1.ListObjects(1)

With TABELA.ListRows(UserForm1.ListBox1.ListIndex + 1).Range
        .Cells(3).Value = UserForm1.TDATA.Value
        .Cells(4).Value = UserForm1.THSAÍDA.Value
        .Cells(5).Value = UserForm1.TKMINICIO.Value
        .Cells(6).Value = UserForm1.TVEÍCULO.Value
        .Cells(7).Value = UserForm1.TMOTORISTA.Value
        .Cells(8).Value = UserForm1.TSERVIÇO.Value
        .Cells(9).Value = UserForm1.TOSCOLAFI.Value
        .Cells(10).Value = UserForm1.THCHEGADA.Value
        .Cells(11).Value = UserForm1.TKMFINAL.Value
        .Cells(14).Value = UserForm1.TABASTECIMENTO.Value
        .Cells(15).Value = UserForm1.TPOSTO.Value
        .Cells(16).Value = UserForm1.TQTDLITROS.Value
        .Cells(17).Value = UserForm1.TNOTA.Value
        .Cells(18).Value = UserForm1.TMANUTENÇÃO.Value
        .Cells(19).Value = UserForm1.TFRETE.Value
        .Cells(20).Value = UserForm1.TDATAPGTO.Value
        .Cells(21).Value = UserForm1.THEXTRAAM.Value
        .Cells(22).Value = UserForm1.THEXTRAPM.Value
        .Cells(23).Value = UserForm1.TALIMENTAÇÃO.Value
        .Cells(25).Value = UserForm1.TOBSERVAÇÕES.Value

End With

Call ATUALIZAR_LISTBOX
Call LIMPAR_FORMULÁRIO
MsgBox "ATUALIZADO COM SUCESSO!"
BLOQUEADO = False

End Sub
O desafio agora é parte da exclusão da linha com base no registro selecionado no ListBox, como minha tabela e ListBox estão trabalhando com RowSource, ainda não encontrei a solução (para selecionar um registro no listbox e excluir toda a linha na respectiva tabela).

Abs,
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