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
#57859
Comecei a usar o VBA a pouco tempo e queria saber se alguém pode me ajudar com uma atividade. Eu quero fazer um formulário, onde quando o usuário escolher um sabor de bolo o valor unitário, do bolo escolhido, apareça automaticamente na caixa de texto do campo preço.

Imagem

O código do VBA está assim

Private Sub btnSalvar_Click()

linhaCadastro = Range(“A1”).End(xlDown).Row + 1

Cells(linhaCadastro, 1) = caixaTxtNotaFiscal.Value
Cells(linhaCadastro, 2) = caixaTxtCidade.Value
Cells(linhaCadastro, 3) = caixaTxtData.Value
Cells(linhaCadastro, 4) = CaixaCombinacao_Produto.Value
Cells(linhaCadastro, 5) = caixaTxtPreco.Value
Cells(linhaCadastro, 6) = caixaTxtQuantidade.Value
Cells(linhaCadastro, 7) = caixaTxtTotal.Value

End Sub
_________________________________________________________________
Private Sub btnCancelar_Click()

Unload Registro_Vendas

End Sub
___________________________________________________________________
Private Sub caixaTxtQuantidade_AfterUpdate()

valorPreco = caixaTxtPreco.Value
valorQtd = caixaTxtQuantidade.Value
resultadoMultiplicacao = valorPreco * valorQtd

caixaTxtTotal = resultadoMultiplicacao

End Sub
___________________________________________________________________
Private Sub UserForm_Click()

End Sub
___________________________________________________________________
Private Sub UserForm_Initialize()

ultimaLinha = Sheets(“Dados”).Range(“A1”).End(xlDown).Row
valorCidade = Sheets(“Dados”).Range(“D2”).Value

CaixaCombinacao_Produto.RowSource = “Dados!A2:A” & ultimaLinha
caixaTxtCidade = valorCidade
caixaTxtData = Date

End Sub
#57861
Boas!

Seria possível disponibilizar o ficheiro em anexo para poder ajudar melhor?

Obrigado. :D
#57862
No envento change da CaixaCombinacao_Produto insira o seguinte código:
Código: Selecionar todos
    linha = WorksheetFunction.Match(CaixaCombinacao_Produto.Value, Sheets("Dados").Range("A1:A20"), 0)
    preco = Sheets("Dados").Cells(linha, 2).Value
    caixaTxtPreco.Value = preco
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