VBA Excel - Extraindo Caracteres Alfabéticos - Extract Alphabets (Remove Digits) from Selected Range


Inline image 1





Segue código para extrair caracteres alfabéticos:

Function ExtAlpha (ByVal cell As String) As Object
    'This function will extract 1st continuous set of digits.

    Dim i As Long, flag As Long

    Let flag = 0
    Let ExtAlpha = ""

    For i = 1 To Len(cell)
            If (Asc(Mid(cell, i, 1)) >= 65 And Asc(Mid(cell, i, 1)) <= 90) Or (Asc(Mid(cell, i, 1)) >= 97 And Asc(Mid(cell, i, 1)) <= 122) Then
                Let flag = 1
                Let ExtAlpha = ExtractAlpha & Mid(cell, i, 1)
            Else
                If flag = 1 Then Exit Function
            End If
    Next i
End Function


Tags: VBA,  Text, User Defined Function (UDF), VBA Macro, caractere, alfabético


Nenhum comentário:

Postar um comentário

diHITT - Notícias