Skip to content

Instantly share code, notes, and snippets.

@mrioqueiroz
Last active September 6, 2020 15:48
Show Gist options
  • Save mrioqueiroz/61d15111581d627a4219331506f7005d to your computer and use it in GitHub Desktop.
Save mrioqueiroz/61d15111581d627a4219331506f7005d to your computer and use it in GitHub Desktop.
Macro VBA para enviar CPF e CNPJ para Área de Transferência removendo os caracteres especiais
Sub RemoverFormatoECopiar()
Dim textoOriginal As String
Dim novoTexto As String
Dim contador As Integer
Dim areaDeTransferencia As New MSForms.DataObject
textoOriginal = ActiveCell.Value
For contador = 1 To Len(textoOriginal)
Dim caractere As String
caractere = Mid(textoOriginal, contador, 1)
If IsNumeric(caractere) Then
novoTexto = novoTexto & caractere
End If
Next
areaDeTransferencia.SetText novoTexto
areaDeTransferencia.PutInClipboard
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment