koll4u Posted May 7, 2012 at 09:11 AM Report #453489 Posted May 7, 2012 at 09:11 AM Bom dia pessoal, Eu tenho uma duvida , eu quero fazer em VBA uma funçao, Cells(i, 2) = "=Left(A2, Find(" - ";A2,2)-2)", esta mesma. Eu tentei desta maneira : For m = 2 To j Step 1 If Cells(m, 1) = "" Then Cells(m, 2) = "" Else cadeia = Fecho_11.Cells(m, 1).Value posicao = InStr(m, cadeia, "-") cadeia2 = Left(cadeia, posicao - 2) Fecho_11.Cells(m, 2).Value = cadeia2 End If On Error Resume Next Next m Visto que nao esta a funcionar o que estara errado ?
Xatissimo Posted May 7, 2012 at 09:37 AM Report #453493 Posted May 7, 2012 at 09:37 AM Boas koll4u Que erro está a dar? Abraço
koll4u Posted May 7, 2012 at 09:39 AM Author Report #453495 Posted May 7, 2012 at 09:39 AM Nao esta a dar erro , mas nao estao a aparecer os valores ...
Xatissimo Posted May 7, 2012 at 09:42 AM Report #453496 Posted May 7, 2012 at 09:42 AM consegues por um breakpoint nisso e correr linha a linha com F8? Abraço
koll4u Posted May 7, 2012 at 09:45 AM Author Report #453498 Posted May 7, 2012 at 09:45 AM Xatissimo Esta a dar erro : cadeia = Fecho_11.Cells(m, 1).Value, nesta linha. Abraço
Xatissimo Posted May 7, 2012 at 09:47 AM Report #453499 Posted May 7, 2012 at 09:47 AM Que valor tens nessa célula? Fecho_11 é o nome da folha, certo?!
koll4u Posted May 7, 2012 at 09:48 AM Author Report #453500 Posted May 7, 2012 at 09:48 AM Sim fecho_11 e o nome da folha . O valor que tenho la é este : 00 - CONTAS DE PASSAGEM O que quero fazer é retirar o valor antes do "-", neste caso é o 00.
Xatissimo Posted May 7, 2012 at 09:51 AM Report #453501 Posted May 7, 2012 at 09:51 AM Bem, antes de ver se a fórmula está correcta e só por descargo de consciência, substitui 'Fecho_11.Cells(m, 1).Value' por 'ActiveWorkbook.Sheets("Folha_11").Cells(m,1).Value'.
koll4u Posted May 7, 2012 at 09:55 AM Author Report #453502 Posted May 7, 2012 at 09:55 AM Ok , essa parte ja esta resolvida, agora esta a dar outro erro . Fecho_11.Cells(m, 2).Value = cadeia2 nesta linha de codigo esta a aparecer o erro '424' Object required . Abraço
Xatissimo Posted May 7, 2012 at 09:57 AM Report #453503 Posted May 7, 2012 at 09:57 AM Faz a mesma substituição nessa linha.
koll4u Posted May 7, 2012 at 10:01 AM Author Report #453504 Posted May 7, 2012 at 10:01 AM Ok ja substitui , estava a dar bem , ate 00.1 - Contas Passagem - Clientes, quando aparece assim , ele transforma o 00.1 para 0,1 , e eu necessito de 00.1 ... Isto sucessivamente em todos os 00.2, 11.1, 11.2 e assim sucessivamente... So quando é tipo 00.1.9 é que aparece bem
Xatissimo Posted May 7, 2012 at 10:04 AM Report #453505 Posted May 7, 2012 at 10:04 AM na linha onde fizeste a ultima substituição Fecho_11.Cells(m, 2).Value = cadeia2 substitui 'Value' por 'Text' e tenta de novo.
koll4u Posted May 7, 2012 at 10:22 AM Author Report #453509 Posted May 7, 2012 at 10:22 AM Ok ja substitui , e agora esta a dar o erro '1004' Nao é possivel definir a propriedade Text da class Range
Xatissimo Posted May 7, 2012 at 10:23 AM Report #453510 Posted May 7, 2012 at 10:23 AM Esquece esta última substituição que não vai funcionar. imediatamente antes desta linha de texto, insere a seguinte linha: activeworkbook.sheets("Fecho_11").cells(m,2).numberformat = "@" Abraço
koll4u Posted May 7, 2012 at 10:25 AM Author Report #453511 Posted May 7, 2012 at 10:25 AM MUITO MUITO MUITO obrigado Problema resolvido . Abraço
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now