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.
#68377
Boa noite amigos!

Preciso adicionar uma apostrofe quando ele acha um texto com uma.

Esse macro me atende bem.
Código: Selecionar todos
Sub FindApos2()
Dim c As Range
Dim RngToCheck As Range

Set RngToCheck = [b12]

For Each c In RngToCheck
If c.PrefixCharacter = "'" Then

Range("a12").Value = "''" & c.Value
 Dim x As String, z As String

    x = Range("A12")
    z = "''" & Mid(x, 2, Len(x) - 2) & ""
    Range("a12").Value = z



End If
Next c
End Sub
porém, gostaria fazer um loop dele seguindo as células até achar uma em branco, ai para.

Obrigado pela atenção.
#68389
Olá, @Rabatini .
#
Experimente:
Código: Selecionar todos
Sub FindApos2V2()
 Dim c As Range
  For Each c In Range("B12:B" & Cells(Rows.Count, 2).End(3).Row)
   If c.PrefixCharacter = "'" Then
    c.Offset(, -1).Value = "''" & Left(c.Value, Len(c.Value) - 1)
   End If
  Next c
End Sub
Rabatini agradeceu por isso
#68391
osvaldomp escreveu:Olá, @Rabatini .
#
Experimente:
Código: Selecionar todos
Sub FindApos2V2()
 Dim c As Range
  For Each c In Range("B12:B" & Cells(Rows.Count, 2).End(3).Row)
   If c.PrefixCharacter = "'" Then
    c.Offset(, -1).Value = "''" & Left(c.Value, Len(c.Value) - 1)
   End If
  Next c
End Sub
Obrigado Osvaldo, Me atendeu perfeitamente!!!!

Feliz natal pra vc!
osvaldomp agradeceu por isso
#68392
Que bom que atendeu. :)

Grato por retornar.

Feliz Natal também a você e sucesso no Ano Novo.
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