Saturday, 9 November 2013

How to Extract Text Characters from Alphanumeric Strings from a Range or Cell Value

Excel VBA Macro to Extract Text  from Alphanumeric Strings from a Range or Cell 
Sub ExtractNumbers()
Dim i As Integer
Dim j As Integer

On Error Resume Next

For i = 2 To 10                'Rows Having Alpha Numeric Strings

If Cells(i, 1) = "" Then Exit For

For j = 1 To Len(Cells(i, 1))
If WorksheetFunction.IsText(Mid(Cells(i, 1), j, 1) + 0) = True Then
Cells(i, 2) = Cells(i, 2) & Mid(Cells(i, 1), j, 1)
End If
Next j

Next i
End Sub

Output :


String
Extracted Text
A1E5I9O15U
AEIOU

1 comment:

  1. Hi,

    Thanks for your simple tutorial. however can you help to explain a bit what the code stands for line by line? I understand what's the code used for,but still can't understand the code line by line.Thanks

    ReplyDelete

Follow Me by Email

ExcelKingdom-Popular Posts

ExcelKingdom-Random Posts