Código para extrair dígitos:
Function ExtractDigits (ByVal cell As String) As Object'This function will extract 1st continuous set of digits.Dim i As Long, flag As Longflag = 0ExtractDigits = ""
For i = 1 To Len(cell)If Mid(cell, i, 1) >= "0" And _Mid(cell, i, 1) <= "9" Thenflag = 1ExtractDigits = ExtractDigits & Mid(cell, i, 1)ExtractDigits = ExtractDigits * 1ElseIf flag = 1 Then Exit FunctionEnd IfNext iEnd Function
Sub Extract_Digits()' This module will extract digits from selected range of cells using above User-defined function. Dim MyCell As RangeDim tmpCol As IntegerDim flag As BooleantmpCol = Selection.ColumnFor Each MyCell In Selection.CellsMyCell.Value = ExtractDigits(MyCell.Value)NextMyCell = NothingEnd Sub
Reference: