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

Dúvidas sobre cálculos, funções simples e aninhadas, fórmulas matriciais, etc.
Por susev
Posts
#70287
Pessoal, boa tarde.

Preciso formatar a planilha em anexo com os números em forma de processo, assim: 0000000-00.0000.0.00.0000
Já tentei muito, mas o Excel coloca pontos onde não deveria. Conseguem me ajudar, por favor?
Agradeço muito!
Você não está autorizado a ver ou baixar esse anexo.
Editado pela última vez por susev em 14 Abr 2022 às 15:38, em um total de 1 vez.
Por MarcilioLobao
Posts
#70290
susev, Boa tarde.

Utilize esse tipo de formato: 0000000-00\.0000\.0\.00\.0000

Por favor, nos diga se era isso o que você queria.
Espero ter ajudado

14-04-2022-GURU-modelo.xlsx
Você não está autorizado a ver ou baixar esse anexo.
#70296
O Excel é limitado a 15 dígitos e sua formatação precisa de mais de 15 dígitos. Criri um objeto tabela formatado como texto. Criei uma função no VBA para formatar o texto da forma que pediu, sendo acionado a cada vez que vc digitar e der enter.

As macros utilizadas foram:
Código: Selecionar todos
Public Function FormataTexto(vrtTexto As String)
    Dim vrtAcentos      As Variant
    Dim vrtAcento       As Variant
    Dim vrtNovoTexto    As String
    
    vrtAcentos = Array(".", ",", "~", "^", "´", "`", _
                        "-", "_", "+", "=", "{", "}", _
                        "[", "]", "(", ")", "/", "?", _
                        "", "", "")
    
    vrtNovoTexto = vrtTexto
    For Each vrtAcento In vrtAcentos
        vrtNovoTexto = VBA.Replace(vrtNovoTexto, vrtAcento, "")
    Next vrtAcento
    
    FormataTexto = VBA.Left(vrtNovoTexto, 7) & "-" & _
                    VBA.Mid(vrtNovoTexto, 7, 2) & "." & _
                    VBA.Mid(vrtNovoTexto, 10, 4) & "." & _
                    VBA.Mid(vrtNovoTexto, 14, 1) & "." & _
                    VBA.Mid(vrtNovoTexto, 15, 2) & "." & _
                    VBA.Right(vrtNovoTexto, 4)
End Function
Código: Selecionar todos
Private Sub Worksheet_Change(ByVal Target As Range)
    On Error GoTo ErrorHandler
    If Not Application.Intersect(Target, wshTeste.ListObjects("tbTexto").DataBodyRange) Is Nothing Then
        Target.Value2 = FormataTexto(Target.Value2)
    End If
    
ErrorHandler:
    
End Sub
Você não está autorizado a ver ou baixar esse anexo.
#70297
Achei que não podia ter uma coluna adicional. Como pode, melhor usar a solução do @MarcilioLobao .
#70298
susev, Boa tarde.

Fico realmente feliz em ter lhe ajudado.

Obrigado pelo feedback.
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