Thursday, January 12, 2012

User defined function in excel to extract numbers


!..........Use:- To extract numbers--------!

Function EXTRACT_NUMBERS(x) As Variant

Dim c As Variant
c = ""
For i = 1 To Len(Replace(x, " ", ""))
If IsNumeric(Mid(x, i, 1)) = True Then
c = c & Mid(x, i, 1)
End If
Next
EXTRACT_NUMBERS = c

End Function

_________________________________________
Example:-
 =EXTRACT_NUMBERS ("^&&5**111CDFG8899B$$$$$_~%^*")
Result----------------------->51118899

No comments:

Post a Comment

Excel VBA to send email from excel with HTML table in a email body

'' Excel vba script to send email from outlook & email body in HTML table format. ''Write down email body in HTML tags...