Public Function ExtractAlpha(ByVal cell As String) As Object
'This function will extract 1st continuous set of digits.
Dim i As Long, flag As Long
flag = 0
ExtractAlpha = ""
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
flag = 1
ExtractAlpha = ExtractAlpha & Mid(cell, i, 1)
Else
If flag = 1 Then Exit Function
End If
Next i
End Function
Sub Extract_Alpha()
' This module will extract alphabets from selected range of cells using above User-Defined function.
Dim MyCell As Range
For Each MyCell In Selection.Cells
MyCell.Value = ExtractAlpha(MyCell.Value)
Next
MyCell = Nothing
End Sub
'This function will extract 1st continuous set of digits.
Dim i As Long, flag As Long
flag = 0
ExtractAlpha = ""
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
flag = 1
ExtractAlpha = ExtractAlpha & Mid(cell, i, 1)
Else
If flag = 1 Then Exit Function
End If
Next i
End Function
Sub Extract_Alpha()
' This module will extract alphabets from selected range of cells using above User-Defined function.
Dim MyCell As Range
For Each MyCell In Selection.Cells
MyCell.Value = ExtractAlpha(MyCell.Value)
Next
MyCell = Nothing
End Sub
Comments