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.
Por RBShoT
#37146
Boa tarde,
Estou tentando formatar um texto via VBA mas a função parece não funcionar
A1 = 10044026
A2 deveria ficar = 0010044026

Range("A2") = WorksheetFunction.Text(Range("A1"), "0000000000")
Mas o valor retornado no A2 não altera, permanece o 10044026.
#37147
Código: Selecionar todos
Range("A2").NumberFormat = "@"
Range("A2").Value = WorksheetFunction.Text(Range("A1").Value, "0000000000")
ou
Código: Selecionar todos
Range("A2").NumberFormat = "@"
Range("A2").Value = Format(Range("A1").Value, "0000000000")
Por RBShoT
#37172
osvaldomp escreveu:
Código: Selecionar todos
Range("A2").NumberFormat = "@"
Range("A2").Value = WorksheetFunction.Text(Range("A1").Value, "0000000000")
ou
Código: Selecionar todos
Range("A2").NumberFormat = "@"
Range("A2").Value = Format(Range("A1").Value, "0000000000")
Bom dia prezado osvaldomp,
Funcionou,
no caso faltou apenas o .Value depois do Range("A1").
Se póssivel me explique, o porque da linha: Range("A2").NumberFormat = "@"
#37175
RBShoT escreveu:Se póssivel me explique, o porque da linha: Range("A2").NumberFormat = "@"

O comando acima formata a célula A2 como Texto. O conteúdo que você deseja inserir (0010044026) deve ser inserido em célula formatada como Texto, se não, o Excel desconsidera os zeros iniciais.

dica - para saber mais sobre comandos VBA clique sobre o comando e aperte F1.
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