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
  • Avatar do usuário
Por ramonmattos
Posts
#5009
Boa noite,
Desejo extrair da célula E10, a string “2.5” onde o valor real da célula, é: “2.5-OBRAS (3)”
Estou utilizando a seguinte função:
Range("B10").Value = Left(Range("E10"), Left(Right(Range("E10"), 2), 1))
Porem, na célula B10 não aparece o valor 2.5 e sim 2,5.
Já tentei replace / str / o diabo a 4 e não consigo isto...teriam como me ajudar...
Desde já agradeço
Avatar do usuário
Por alexandrevba
Avatar
#5010
Boa noite!!!

Meu sistema operacional em casa é no idioma inglês e meu Office também.
Código: Selecionar todos
=LEFT(E10;3)
Tente aplicar no VBA...=LEFT(E10,3)

Meu resultado foi 2.5

Att
Por EdivanCabral
Posts
#5015
Olá tudo bem espero que sim...

Tente antes de atribuir o valor usar a formatação para texto assim:

Range("E10").NumberFormat = "@"
Range("E10").Value = Left(Range("B10").Value, 3)


Espero que tenha ajudado, se puder visite meu blog

programacaopassoapasso.wordpress.com
Por LucasJose
Posts
#5303
Olá Colega!
Se a sua intenção é extrair os primeiros caracteres que sejam números a virgula e os outros números, ai vai o cod

Dim caract As Interger
Dim texto As String
Dim passouvirgula As Boolean

For caract = Len(Range("E10").value)
If IsNumeric(Mid(Range("E10").value,cont,cont)) then
texto = texto & Mid(Range("E10").value,cont,cont)
If Mid(Range("E10").value,cont,cont) = "," then passouvirgula = true
ElseIf passouvirgula = true then
Exit sub
End if
Next

é só colocar dentro de um procedimento blz, espero ter ajudado, qualquer duvida estou a disposição!
Avatar do usuário
Por Reinaldo
Avatar
#5307
Teste
Código: Selecionar todos
Dim tp() As String
tp = Split(Range("E10"), "-")
Range("B10").NumberFormat = "@"
Range("B10").Value = tp(0)

'ou
Range("B10").NumberFormat = "@"
Range("B10").Value = Left(Range("E10"), 3)
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