Thursday, January 12, 2012

User Defined Function in Excel to extract numbers & then sum of the values


!.......Below Code to Create User Defined Functions in Excel........!


Use:- To extract numbers & then sum of the values.....


Function EXTRACT_NUMBERS_and_Sum(x) As Variant

Dim c As Variant
c = 0
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_and_Sum = c

End Function

______________________________________________

Example:-
= EXTRACT_NUMBERS_and_Sum("^&&5**111CDFG8899B$$$$$_~%^*")
Result-------------->  42

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...